Hi, i could not do with expand statement. I tried to write a sample below that describes what I am trying to do. There is a metarial data and the factory data. Each vehicle on material data try to use its liquid and solid stock by delivering it to the factories. Vehicles that have liquid volume goes to factories that have liquid inventory. And I am trying to write a flow constraint per vehicle if inventory is liquid on factory data then use the liquid variable on material data else use solid variable. Thx:) data material;
input liquid solid vehicle ;
datalines ;
50 10 1
40 30 2
10 60 3
0 100 4
100 0 5
;
data factory;
input id inventory $ x y supply;
datalines;
1 liquid 10 20 10
2 solid 11 20 20
3 liquid 15 30 40
4 liquid 12 20 100
5 solid 13 15 100
; proc optmodel;
set material;
num liquid{material};
num solid{material};
num vehicle{material};
read data material into material=[vehicle] liquid solid;
set factory;
num id{factory};
str inventory{factory};
num east{factory};
num north {factory};
num supply{factory};
read data factory into factory=[id] inventory east north supply;
set EDGES = {i in factory, j in factory: i < j};
num distance {<i,j> in EDGES} =
sqrt((east[i]-east[j])^2+(north[i]-north[j])^2);
var UseNode {factory} binary;
var UseEdge {edges,material} binary;
min TotalDistance
= sum {<i,j> in EDGES,k in material} distance[i,j] * UseEdge[i,j,k];
con flow{k in material}:
sum{<i,j> in edges} supply[i]*Useedge[i,j,k]
<= (if inventory[i]="liquid" then liquid[k] else solid[k] );
solve;
quit;
... View more