SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-10-2013 10:54 AM

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 BIDSj=ll)} Assigned_Truckloads[i,j] = 1;

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

constraint LaneToOneCarrier {ii in CARRIERS}:

sum{<i,j> in BIDSi=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;

Accepted Solutions

Solution

05-14-2013
11:41 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-14-2013 11:41 AM

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.

Thanks for your time though,

-Mike

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-10-2013 11:52 PM

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?

Solution

05-14-2013
11:41 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-14-2013 11:41 AM

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.

Thanks for your time though,

-Mike

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-14-2013 11:43 AM

No problem!