Hi all,

Am pretty new to SAS/OR and to start with, am just trying to solve a simple assignment problem. Three carriers (Carrier 1, Carrier 2, Carrier 3) and three lanes (Lane 1, Lane 2, Lane 3) with their rates. Simple formulation to minimize the cost such that one carrier is assigned one lane and vice-versa. My Data sets are as below. Something is wrong in my coede, not understand what should I do to make it work ?? Please guide !!

DATA

Carrier             Lane         RatePerMile

 Carrier 1 Lane 1 11 Carrier 1 Lane 2 14 Carrier 1 Lane 3 6 Carrier 2 Lane 1 8 Carrier 2 Lane 2 10 Carrier 2 Lane 3 11 Carrier 3 Lane 1 9 Carrier 3 Lane 2 12 Carrier 3 Lane 3 7

DATA1

 One Carrier 1 Two Carrier 2 Three Carrier 3

DATA2

 One Lane 1 Two Lane 2 Three Lane 3

I have introduced binary variable and my code as below-

proc optmodel;

set <string, string> BIDS;

number RatePerMile {BIDS} init 0;   /*parameters*/

into BIDS = [Carrier Lane]

RatePerMile;

set <string> CARRIERS;

string CarrierName {CARRIERS};  /*parameters*/

into CARRIERS = [CarrierID]

CarrierName;

set <string> LANES;

string LaneName {LANES};  /*parameters*/

into LANES = [LaneID]

LaneName;

/*decision variables */

/*constraints */

/* 1.. One carrier to One Lane. */

constraint CarrierToOneLane {ll in LANES}:

sum{<i,j> in BIDS:(j=ll)} Assigned_Truckloads[i,j] = 1;

/* 2.. One Lane to one carrier.*/

constraint LaneToOneCarrier {ii in CARRIERS}:

sum{<i,j> in BIDS:(i=ii) } Assigned_Truckloads[i,j] = 1;

/*objective function*/

min Total_Cost =

sum{<i,j> in BIDS}

solve;

expand;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Leo,

Thank a bunch for looking into my code. I figured out thatmy CARRIERS and LANES sets had different values (One, Two & Three), whereas the SUM statement was looping over rates data set DATA (Carrier1..Lane1....). Hence it was going infeasible. I took out that CarrierID column (One, Two, Three) and made CarrierName as actual "key index" column contianing actual index values.And it worked.

Sorry for confusion, long story short- I was not reading consisetent data and hence error.

-Mike

3 REPLIES 3

Hi Mike,

Your code overall looks reasonable. One thing I would do is use a single dataset and derive the LANES and CARRIER sets from BIDS.

You should get more specific answers if you post your log file. Where exactly are you stuck?

Hi Leo,

Thank a bunch for looking into my code. I figured out thatmy CARRIERS and LANES sets had different values (One, Two & Three), whereas the SUM statement was looping over rates data set DATA (Carrier1..Lane1....). Hence it was going infeasible. I took out that CarrierID column (One, Two, Three) and made CarrierName as actual "key index" column contianing actual index values.And it worked.

Sorry for confusion, long story short- I was not reading consisetent data and hence error.