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

01-12-2015 06:12 PM

Hi Everyone,

I have some questions about data set definition in an optimization model.

One of the constraints is: sum {i in DivBlocks* * BlockAssign[i,j] <= MaxDivPrntArea .*

But I do not know how to create the data set of MaxDivPrntArea, can you tell me how to create it?

PS: the length of MaxDivPrntArea

Thank you very much for your help!

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

01-12-2015 06:22 PM

The index set for MaxDivPrntArea should match (or be a subset of) the index set for your constraint. More explicitly, suppose you have a SAS data set called mydata that contains k and MaxDivPrntArea. Then you need something like this:

set KSET;

num MaxDivPrntArea {KSET};

read data mydata into KSET=

con Mycon {k in KSET}:

sum {i in DivBlocks* * BlockAssign[i,j] <= MaxDivPrntArea ;*

Or are you having trouble creating the mydata SAS data set itself?

In any case, you might find it useful to read some of the examples here:

SAS/OR(R) 13.2 User's Guide: Mathematical Programming Examples

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

01-13-2015 12:37 PM

Hi RobPratt,

Thank you for your answers! I am not sure how to create DivBlocks either.

I want to create a set DivBlocks which has 2 levels indices: 1. index k for the first level; 2. given a particular level, DivBlocks

Because the length of the first level of DivBlocks may change for different applications, I think it would be better not to list them one by one. Could you help me to get the answers? Thank you for your kind help!

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

01-13-2015 01:36 PM

First create a SAS data set as follows:

data indata;

input k i;

datalines;

1 1

1 2

1 5

2 3

2 7

3 4

3 6

3 8

3 9

;

In PROC OPTMODEL, you can read these pairs like this:

set <num,num> KI;

read data indata into KI=[k i];

One approach to express the desired constraint is to use an implicit slice:

set KSET = setof {<k,i> in KI} k;

con Mycon {k in KSET}:

sum {<(k),i> in KI, j in Pages} BlockSize* * BlockAssign[i,j] <= MaxDivPrntArea ;*

If you insist on using DivBlocks, here is an alternative approach that uses the SETOF operator again:

set DivBlocks {k in KSET} = setof {<(k),i> in KI} i;

con Mycon {k in KSET}:

sum {i in DivBlocks* * BlockAssign[i,j] <= MaxDivPrntArea ;*

A third approach passes through the KI set only once to construct both KSET and DivBlocks:

set KSET init {};

set DivBlocks {KSET} init {};

for {<k,i> in KI} do;

KSET = KSET union {k};

DivBlocks

end;

con Mycon {k in KSET}:

sum {i in DivBlocks* * BlockAssign[i,j] <= MaxDivPrntArea ;*

The doc link referenced in my previous reply contains numerous relevant examples. Search for "sets indexed by other sets" in the pdf.

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

01-13-2015 02:33 PM

Hi RobPatt,

Thank you a lot for your help!