BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Vane08
Fluorite | Level 6
/* II-  PROGRAME OPTMODEL 															*/ 
	/***********************************************************************************/
					proc optmodel; 
						
						/* 0 Tableau des chemins & Marges								*/ 
						/************************************************************/
								/* declaration de paramètre 	*/
						
						Set <string> Vecteur_&Typej._&Heure._&Annee.; 
						Set <string> Marge_&Typej._&Heure._&Annee.; 
						num Tij{Vecteur_&Typej._&Heure._&Annee.};

					    num marges{Marge_&Typej._&Heure._&Annee.};
						num STDMarges{Marge_&Typej._&Heure._&Annee.};
						num Nobs{Marge_&Typej._&Heure._&Annee.};
						num chemin{Vecteur_&Typej._&Heure._&Annee., Marge_&Typej._&Heure._&Annee.};
								
						/* Reading data 													*/ 
						/******************************************************************/

					 	read data Vecteur_&Typej._&Heure._&Annee. into 
							Vecteur_&Typej._&Heure._&Annee. = [Vecteur] Tij; 
						print Tij;

					    read data Marge_&Typej._&Heure._&Annee. into 
							Marge_&Typej._&Heure._&Annee. = [N] 
							marges = marges
							STDMarges = STDMarges
							NObs = Nobs 
							{p in Vecteur_&Typej._&Heure._&Annee.} <chemin[p,N]= col(p)>;
						print  marges STDMarges Nobs chemin;
							

						/* III Resolution  												*/ 
						/*********************************************************************/
							/* V-1) Déclaration de variables */ 
							
							var  X{Vecteur_&Typej._&Heure._&Annee.} >= 0;
							Var  Y{Marge_&Typej._&Heure._&Annee.} >= 0 ; 
							

							/* V-2) La fonction objective : minimisation de la variance */ 

							minimize f = sum{p in Vecteur_&Typej._&Heure._&Annee.} (X[p]-Tij[p])**2/(Tij[p]/3)**2 + sum{r in Marge_&Typej._&Heure._&Annee.} ((Y[r]- Marges[r])**2/(STDMarges[r]**2/Nobs[r]));



							/* V-3) subject to the following constraints */

							Con Bornes{r in Marge_&Typej._&Heure._&Annee.}: sum{p in Vecteur_&Typej._&Heure._&Annee.} chemin[p, r]*X[p] = Y[r];

/* Con Condtion1{r in Marge_&Typej._&Heure._&Annee. :}: If r = 17 then sum{p in Vecteur_&Typej._&Heure._&Annee.} chemin[p, r]*X[p] > 0;
Con Condtion1{r in Marge_&Typej._&Heure._&Annee. :}: If r = 16 then sum{p in Vecteur_&Typej._&Heure._&Annee.} chemin[p, r]*X[p] > 0;*/
							
						
							
						 solve ;
						print X;
						Print Y;
						
						
						create data Vecteur_est_&Typej._&Heure._&Annee. from [p] Tij&Annee. = X ;
						create data Marge_est_&Typej._&Heure._&Annee. from [r]  Marges&Annee. = Y ;
						

Good morning, 

 

I want to make conditions in my constraint because in the solutions of X and Y, I need some sum in the line of Y like : 

 

1) In the first solution Y: (Marge_est_&Typel.&Heure._&Annee. ) with Y[r] 

                 ==> I need that  Y[16] = Y[17] +Y[18]   with Y[17]#0 and Y[18] #0 

                       (there is some case like those lines but not all the line in the table, it is a transportation problem..) 

                                                 and in the same time

2) I have the constraint that the sum in line of  X[1...52]*chemin[52, 31]  is equal at the sum of Y[1..31]  

                      for example : for the first line of Y   : [1...52]*chemin[1..52, 1] = Y[1] ; I have no problem to write this second constraint "con" like in the code I sent here in Pj. 

 

==>The origin of this problem is that in my  real data set in the table   Marge_&Typel.&Heure._&Annee.  :

                                               the line 17 = 0 , the line 18 = 0 so the QP affect s100% of Y[16] in just one of Y[18] or Y[17]

 

==>So I thought that the solutions were : making  some condition contraint to estimates line in this case to have in the estimation not Y[16] =  Y[17]  +0        with Y[18] = 0

                   but Y [16] = Y[17] +Y[16]   with Y[18] #0 and Y[17] #0

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

@Vane08:  Just for good housekeeping purposes, mark this topic as solved.  I see you've already posted this question in the OR forum, so enter a response on this topic with a link to its twin, and then mark your response as solved.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

3 REPLIES 3
Ksharp
Super User

You should post it at OR forum. Calling @RobPratt

 

Vane08
Fluorite | Level 6
You're right ! Thank you
mkeintz
PROC Star

@Vane08:  Just for good housekeeping purposes, mark this topic as solved.  I see you've already posted this question in the OR forum, so enter a response on this topic with a link to its twin, and then mark your response as solved.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 850 views
  • 0 likes
  • 3 in conversation