Pyrite | Level 9

## Selecting modes and service levels from Origin to Destination

Hi Rob

I am trying to solve this problem. I have a set of Origins (O), set of destinations (D). I have two set of products (called p1 and p2).  In between these origins and destinations, Between the origin and destinations, I have 3 modes of transport possible (Air, Ocean and Truck). In Air, I have two service levels STD/EXP. In truck I have 2DAY/5DAY/7DAY. In Ocean, I have Slow/Fast. All these modes and service levels from O and D comes with a cost and we want to chose minimal cost of routing a shipment. The constraints that I have is for any give product, I can only choose one of the mode (either Air, Ocean or Truck). But I have the liberty to choose any service level for a given mode. For example, for product p1, for a shipment 1, if the model deems Air as the optimal mode, for some shipments for p1 product, I can chose STD and I can chose EXP for some other shipments for p1.  The input that we have is Shipments (shipment numbers 1 to 100) from O to D. Each shipment has its own weight.  We want to find , for a given shipment, what is the minimal cost way to ship . Of course, there are other constraints like if we are using STD for example, the shipment weight has to be at least 50 kgs.  If it is 7 DAY then it needs to be at least 100 Kgs.  The trouble I am having is I don't know how to select only 1 out of 3 modes for all shipments, yet can have the model allocate among many service levels for a given mode . Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: Selecting modes and service levels from Origin to Destination

For simplicity, I will demonstrate for only one O-D pair and omit those indices.  Suppose binary decision variable IsProductShipmentModeLevel[p,s,m,sl] indicates whether product p and shipment s use mode m with service level sl and binary decision variable IsProductMode[p,m] indicates whether product p uses mode m.  Then impose the following constraints:

``````   con OneModeLevel {p in PRODUCTS, s in SHIPMENTS}:
sum {<m,sl> in MODE_LEVEL} IsProductShipmentModeLevel[p,s,m,sl] = 1;

con ModeLevelImpliesMode {p in PRODUCTS, s in SHIPMENTS, m in MODES}:
sum {<(m),sl> in MODE_LEVEL} IsProductShipmentModeLevel[p,s,m,sl] <= IsProductMode[p,m];

con OneMode {p in PRODUCTS}:
sum {m in MODES} IsProductMode[p,m] = 1;
``````
4 REPLIES 4
SAS Super FREQ

## Re: Selecting modes and service levels from Origin to Destination

For simplicity, I will demonstrate for only one O-D pair and omit those indices.  Suppose binary decision variable IsProductShipmentModeLevel[p,s,m,sl] indicates whether product p and shipment s use mode m with service level sl and binary decision variable IsProductMode[p,m] indicates whether product p uses mode m.  Then impose the following constraints:

``````   con OneModeLevel {p in PRODUCTS, s in SHIPMENTS}:
sum {<m,sl> in MODE_LEVEL} IsProductShipmentModeLevel[p,s,m,sl] = 1;

con ModeLevelImpliesMode {p in PRODUCTS, s in SHIPMENTS, m in MODES}:
sum {<(m),sl> in MODE_LEVEL} IsProductShipmentModeLevel[p,s,m,sl] <= IsProductMode[p,m];

con OneMode {p in PRODUCTS}:
sum {m in MODES} IsProductMode[p,m] = 1;
``````
Pyrite | Level 9

## Re: Selecting modes and service levels from Origin to Destination

thank you rob.

I think I got it/  The MODE_Level that one is that a cartesian join of all modes and service levels possible?

thanks a lot again

SAS Super FREQ

## Re: Selecting modes and service levels from Origin to Destination

Not a Cartesian product, but a union of Cartesian products:

``````proc optmodel;
set MODE_LEVEL = (/Air/ cross /STD EXP/) union (/Truck/ cross /'2DAY' '5DAY' '7DAY'/) union (/Ocean/ cross /Slow Fast/);
put MODE_LEVEL=;
quit;``````
```MODE_LEVEL={<'Air','STD'>,<'Air','EXP'>,<'Truck','2DAY'>,<'Truck','5DAY'>,<'Truck','7DAY'>,<'Ocean','Slow'>,<'Ocean','Fast'>}
```
Pyrite | Level 9

## Re: Selecting modes and service levels from Origin to Destination

wow this is awesome. i never knew this syntax.

thank you for everything.

Discussion stats
• 4 replies
• 875 views
• 0 likes
• 2 in conversation