Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Constraint error proc optmodel

Reply
New Contributor
Posts: 4

Constraint error proc optmodel

Hello, 

 

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];

solve;

print TotalCost;

print inflow;
print outflow;
quit;

SAS Employee
Posts: 449

Re: Constraint error proc optmodel

 

 

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.

Ask a Question
Discussion stats
  • 1 reply
  • 200 views
  • 0 likes
  • 2 in conversation