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*/
Read data Optimize.data
into BIDS = [Carrier Lane]
RatePerMile;
set <string> CARRIERS;
string CarrierName {CARRIERS}; /*parameters*/
Read data Optimize.data1
into CARRIERS = [CarrierID]
CarrierName;
set <string> LANES;
string LaneName {LANES}; /*parameters*/
Read data OPTIMIZE.DATA2
into LANES = [LaneID]
LaneName;
/*decision variables */
var Assigned_Truckloads{BIDS} binary;
/*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}
RatePerMile[i,j] * Assigned_Truckloads[i,j];
solve;
expand;
quit;