Turn on suggestions

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

Showing results for

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-12-2015 06:12 PM
(944 views)

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!

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi RobPatt,

Thank you a lot for your help!

⏰

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.** **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.