BookmarkSubscribeRSS Feed
Calcite | Level 5



I am trying to use the procoptmodel to solve a minimization of total cost. I have crossdock facilities that, when used, have a fixed cost. However, my solution is using two crossdock facilities, but only adding the cost for one of them and ignoring the other cost even though the facility is being used. The constraint where I tried to bind the use and cost is called xMaxP. My code is posted below, any suggestions? 


proc optmodel;

Set Ps={'South Carolina','New York','Alaska','Rhode Island'};
Set Ts={'South Dakota','Nebraska','Indiana'};
Set Ds={'North Dakota','Hawaii','Pennsylvania','Illinois'};

number MaxP{Ps}=[
40 25 37 34];

number MinD{Ds}=[
21 15 12 15];

number InspectionCapacity{Ts}=[
40 45 42];

number FixedInspectionCost{Ts}=[
950 850 950];

number incost{Ps,TS}=[
43 26 44
40 33 39
31 36 45
45 27 40];

number outcost{Ts,Ds}=[
44 27 41 36
21 33 27 30
34 30 47 48];

var inflow{Ps,Ts}>=0;
var outflow{Ts,Ds}>=0;
var InspectDecision{Ts} binary;

minimize TotalCost= sum{i in Ps, j in Ts} incost[i,j]*inflow[i,j]+sum {j in Ts, k in Ds} outcost[j,k]*outflow[j,k]
+sum{j in Ts}InspectDecision[j]*FixedInspectionCost[j];

con cMaxP{i in Ps}: sum{j in Ts} inflow[i,j]<=MaxP[i];

con cMinD{k in Ds}: sum{j in Ts} outflow[j,k]>=MinD[k];

con NoStock{j in Ts}: sum{i in Ps} inflow[i,j] = sum {k in Ds} outflow[j,k];

con xMaxP{j in Ts}:sum{i in Ps} inflow[i,j]<=InspectionCapacity[j]*sum{j in Ts}InspectDecision[j];


print TotalCost;

print inflow;
print outflow;




You have used j as both a constraint index and a summation index in the xMaxP constraint:

con xMaxP{j in Ts}:sum{i in Ps} inflow[i,j]<=InspectionCapacity[j]*sum{j in Ts}InspectDecision[j];


Corrected version:

con xMaxP{j in Ts}:sum{i in Ps} inflow[i,j]<=InspectionCapacity[j]*InspectDecision[j];


To see that it does what you want, check the two cases InspectDecision[j] = 0 and InspectDecision[j] = 1.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2 in conversation