BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Santha
Pyrite | Level 9

Rob. - This is still a MILP. 

This should be straight forward but I am not getting it correct.  I am trying to have a constraint called "LSP_DC" and an associated "LSP_DCLink" . What I am trying to enforce is that a given LSP should go to "x" number of DCs . I define what x is. This does not seem to do what I want.


proc optmodel;

set<str> Ports=/'SHA' 'YAN'/;
set<str> DC=/'AL1' 'FU1'/;
set<str> LSP=/'MAEU' 'ONEY' 'COSC'/;
set <str> Transit=/'West','East', 'Gulf'/;

num Containers {Ports,DC}= [2000,3000,1000,4000];
print containers;

var Is_LSP {LSP} binary;
var IsLSPDC {LSP,DC} binary;
var IsPortsLSPDC {Ports,LSP,DC} binary;
var IsPortsTransitLSPDC {Ports,Transit,LSP,DC} binary;

/* declare Constants*/
num Min_Qty_LSP=200;

/*RATES*/
num InboundLinehaul {Ports,Transit,LSP,DC}= [40,10,30,5,20,10,
20,6,30,7,3,5,
2,6,2,60,18,4,
32,70,2,30,18,40,
19,10,2,29,3,9,
42,36,79,10,5,14
];

 

/* DECISON VARIABLE */

var ContainersfromPortstoLSPtoDC {Ports,Transit,LSP,DC}>=0;

 

/* IMPLIED VARIABLE */
impvar Inbound_Linehaul_Costs= sum {p in Ports, t in Transit,c in LSP, d in DC} InboundLinehaul [p,t,c,d] *ContainersfromPortstoLSPtoDC [p,t,c,d];
impvar ContainersatLSP{c in LSP}=sum{p in Ports,t in Transit,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d];
impvar ContainersatTransitLSP{t in Transit, c in LSP}=sum{p in Ports,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d];

/* declare Objective Function*/
Min TotalCost = Inbound_Linehaul_Costs;

 

/* GENERAL CONSTRAINTS */
con Min_Qty_at_LSP_is_Respected {c in LSP} :
sum{p in Ports,t in Transit,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d]>=Min_Qty_LSP*Is_LSP[c];

con ModelOutput_Same_As_ModelInput {p in Ports, d in DC}:
sum {t in Transit,c in LSP} ContainersfromPortstoLSPtoDC[p,t,c, d] = Containers [p,d];

con CheckLSP {c in LSP}: ContainersatLSP[c] <= 10000*Is_LSP[c];

 

/*Constraint for retricting LSP-DC: given LSP can go to only "x" number of DC* - in this case x=2/
num MAEU_DCs=2;

fix Is_LSP ['MAEU']=1;
con LSP_DC: sum{d in DC} IsLSPDC['MAEU',d] = MAEU_DCs;
con LSP_DC_Link{p in Ports, t in Transit,c in LSP, d in DC}:
ContainersfromPortstoLSPtoDC[p,t,'MAEU',d] <= 10000 * IsLSPDC['MAEU',d];

 

expand;

solve with milp;

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

OK, thanks for the clarification.  Your constraints enforce only that ContainersfromPortstoLSPtoDC[p,t,c,d] > 0 for some p and t implies IsLSPDC[c,d] = 1, but you need additional constraints to enforce the converse:

 

con LSP_DC_Link2{c in LSP, d in DC}:
   sum {p in Ports, t in Transit} ContainersfromPortstoLSPtoDC[p,t,c,d] >= IsLSPDC[c,d]; 

 

 

View solution in original post

5 REPLIES 5
Santha
Pyrite | Level 9

I changed the constraint to but with no luck yet.

 

con LSP_DC_Link{p in Ports, t in Transit,c in {"MAEU"}, d in DC}:
ContainersfromPortstoLSPtoDC[p,t,'MAEU',d] <= 10000 * IsLSPDC['MAEU',d];

RobPratt
SAS Super FREQ

Sorry, I don't quite follow.  Can you please describe what is wrong with the resulting solution?

Santha
Pyrite | Level 9

Sure. Sorry for not articulating it . 

I have this LSP called "MAEU" . I want this LSP to serve 2 DCs (that is AL1 and FU1). However the model does not allocate MAEU to 2 DCs. It does allocate to only 1 DC. I want any given LSP to serve any number of DCs. That is my objective.

Here is the output:

PortsTransitLSPDestinationScenarioNameContainersfromPortstoLSPtoDCInboundLinehaulInbound_Linehaul_Costs
SHAGulfMAEUAL1PN3158-Alt42002400
SHAGulfONEYAL1PN3158-Alt4180023600
SHAGulfCOSCFU1PN3158-Alt43000412000
YANEastONEYAL1PN3158-Alt4100022000
YANEastCOSCFU1PN3158-Alt44000936000

Please let me know.

RobPratt
SAS Super FREQ

OK, thanks for the clarification.  Your constraints enforce only that ContainersfromPortstoLSPtoDC[p,t,c,d] > 0 for some p and t implies IsLSPDC[c,d] = 1, but you need additional constraints to enforce the converse:

 

con LSP_DC_Link2{c in LSP, d in DC}:
   sum {p in Ports, t in Transit} ContainersfromPortstoLSPtoDC[p,t,c,d] >= IsLSPDC[c,d]; 

 

 

Santha
Pyrite | Level 9

THanks Rob. It worked. 

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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
  • 5 replies
  • 431 views
  • 1 like
  • 2 in conversation