/* 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
@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.
You should post it at OR forum. Calling @RobPratt
@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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.