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

 

Thank you in advance for your response 

@RobPratt

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

If I understand correctly, you should include the following two additional statements:

   con YSum: Y['N16'] = Y['N17'] + Y['N18'];
   for {r in /N17 N18/} Y[r].lb = 1e-3;

 

The first statement declares your new constraint, and the second statement changes the lower bounds on Y['N17'] and Y['N18'] from 0 to 1e-3.  Here, 1e-3 is just an example.  You have to decide for yourself how large Y[r] must be for you to consider it to be positive.

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ

If I understand correctly, you should include the following two additional statements:

   con YSum: Y['N16'] = Y['N17'] + Y['N18'];
   for {r in /N17 N18/} Y[r].lb = 1e-3;

 

The first statement declares your new constraint, and the second statement changes the lower bounds on Y['N17'] and Y['N18'] from 0 to 1e-3.  Here, 1e-3 is just an example.  You have to decide for yourself how large Y[r] must be for you to consider it to be positive.

Vane08
Fluorite | Level 6

Thank you for your response ! It gives me the syntax for a condition but I think that I need changing something in my resolution programm.