BookmarkSubscribeRSS Feed
m3lon00
Calcite | Level 5

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;

1 REPLY 1
RobPratt
SAS Super FREQ

 

 

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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 1 reply
  • 1353 views
  • 0 likes
  • 2 in conversation