Hello,
How can I translate a set of constraints into a "loop of variable fixations"? This is, in the example below I am trying to shift the Loop-constraint to a set of Fix-statements:
* simple transportation model .. ;
%Let Sources=10;
%Let Plants=%Eval(&Sources.*2);
Data Costs;
Do Source=1 To &Sources.;
Do Plant=1 To &Plants.;
Costs=Ranuni(1)*4+19; Output;
End;
End;
Run;
Data Demand;
Do Plant=1 To &Plants.;
Qty=Ranuni(1)*20+200; Output;
End;
Run;
Data Supply;
Do Source=1 To &Sources.;
Qty=Ranuni(1)*15+600; Output;
End;
Run;
Data Fixed;
Source=1; Plant=7; Fixed=50; Output;
Source=1; Plant=8; Fixed=50; Output;
Source=1; Plant=9; Fixed=50; Output;
Source=1; Plant=10; Fixed=50; Output;
Source=2; Plant=9; Fixed=50; Output;
Source=2; Plant=10; Fixed=50; Output;
Run;
Data Costs;
Merge Costs (in=inC) Fixed;
By Source Plant;
If inC;
Run;
Proc Optmodel;
Set <Num,Num> q_w;
Num Costs{q_w};
Num Fixed_F{q_w};
Read Data Costs Into q_w=[Source Plant] Costs=Costs Fixed_F=Fixed;
Set Sources=Setof{<q,w> in q_w} q;
Set Plants=Setof{<q,w> in q_w} w;
Num Demand{Plants};
Num Supply{Sources};
Read Data Demand Into [Plants=Plant] Demand=Qty;
Read Data Supply Into [Sources=Source] Supply=Qty;
Var X{Sources,Plants}>=0;
Con Cns1{q in Sources}:Sum{w in Plants}X[q,w]<=Supply;
Con Cns2{w in Plants}:Sum{q in Sources}X[q,w]>=Demand;
Con Loop{q in Sources, w in Plants:Fixed_F[q,w] ne .}:X[q,w]=Fixed_F[q,w]; * <-- equivalent "Fix"-Loop?;
*Fix X[1,6]=40;
Min Obj=Sum{q in Sources,w in Plants}X[q,w]*Costs[q,w];
Expand;
Solve;
Create Data Result From [Tail Head]={q in Sources, w in Plants} X;
Run;
Thanks & kind regards