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
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-08-2016 05:23 PM

I'm trying to understand how to correctly structure the data in a SAS data set (or in an Excel file that can be converted into a SAS data set via PROC IMPORT) so the index sets and known parameters in the SET and NUM statements don't need to be hard coded within the OPTMODEL procedure.

My end goal is to create a generalizable optimization program that can accomodate any number of values based on a predefined SAS data set that can be read into OPTMODEL, so that if editing is required, all editing is done outside of the OPTMODEL procedure.

Below is a sample program. It executes and runs without error as is, but am having trouble with the issue mentioned above.

Thank you in advance for any help you can provide.

`proc optmodel;`

set DAYS=1..3;

set LAWNS=/Lawn1 Lawn2 Lawn3 Lawn4/;

num RevenueSchedule{DAYS,LAWNS}=[60 35 0 0 0 35 25 20 0 35 25 20];

num TimeAvailable{DAYS}=[8 6 6];

num TimePerLawn{LAWNS}=[6 4 3 3];

var Do{DAYS,LAWNS} >=0 binary;

impvar TimeSpentMowing{d in DAYS}= sum{l in LAWNS} Do[d,l]*TimePerLawn[l];

impvar TimeLeftOver{d in DAYS}= TimeAvailable[d] - TimeSpentMowing[d];

max TotalRevenue=sum{d in DAYS,l in LAWNS} Do[d,l]*RevenueSchedule[d,l];

con TimePerDay{d in DAYS}: TimeSpentMowing[d] <= TimeAvailable[d];

con NotMoreThanOnce{l in LAWNS}: sum{d in DAYS} Do[d,l]<=1;

solve;

print RevenueSchedule TimePerLawn;

print Do TimeAvailable TimeSpentMowing TimeLeftOver;

quit;

Accepted Solutions

Solution

04-08-2016
05:45 PM

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

Posted in reply to jhlaramore

04-08-2016 05:38 PM

Here's one way, using three data sets:

```
data day_data;
input day TimeAvailable;
datalines;
1 8
2 6
3 6
;
data lawn_data;
input lawn $ TimePerLawn;
datalines;
Lawn1 6
Lawn2 4
Lawn3 3
Lawn4 3
;
data day_lawn_data;
input day lawn1-lawn4;
datalines;
1 60 35 0 0
2 0 35 25 20
3 0 35 25 20
;
proc optmodel;
set DAYS;
num TimeAvailable{DAYS};
read data day_data into DAYS=[day] TimeAvailable;
set <str> LAWNS;
num TimePerLawn{LAWNS};
read data lawn_data into LAWNS=[lawn] TimePerLawn;
num RevenueSchedule{DAYS,LAWNS};
read data day_lawn_data into [day] {j in LAWNS} <RevenueSchedule[day,j]=col(j)>;
```

You might also find this book of examples useful:

http://support.sas.com/documentation/cdl/en/ormpex/68157/HTML/default/viewer.htm#titlepage.htm

All Replies

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

Posted in reply to jhlaramore

04-08-2016 05:27 PM

Solution

04-08-2016
05:45 PM

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

Posted in reply to jhlaramore

04-08-2016 05:38 PM

Here's one way, using three data sets:

```
data day_data;
input day TimeAvailable;
datalines;
1 8
2 6
3 6
;
data lawn_data;
input lawn $ TimePerLawn;
datalines;
Lawn1 6
Lawn2 4
Lawn3 3
Lawn4 3
;
data day_lawn_data;
input day lawn1-lawn4;
datalines;
1 60 35 0 0
2 0 35 25 20
3 0 35 25 20
;
proc optmodel;
set DAYS;
num TimeAvailable{DAYS};
read data day_data into DAYS=[day] TimeAvailable;
set <str> LAWNS;
num TimePerLawn{LAWNS};
read data lawn_data into LAWNS=[lawn] TimePerLawn;
num RevenueSchedule{DAYS,LAWNS};
read data day_lawn_data into [day] {j in LAWNS} <RevenueSchedule[day,j]=col(j)>;
```

You might also find this book of examples useful:

http://support.sas.com/documentation/cdl/en/ormpex/68157/HTML/default/viewer.htm#titlepage.htm

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

Posted in reply to RobPratt

04-08-2016 05:49 PM

Thank you, Rob!