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

08-06-2015 04:58 PM

On SAS Proc Optmodel,

I set variable A, which is a 2*2 matrix [p,k]

And variable B, and C are both 2*1 matrix [p,k], where B and C are one particular value of k. Like A = [B,C]

For coding convenience, sometimes I used A, and sometimes I used B and C.

I may need a constraint to describe the relationship between them. A = [B, C]

How can I put it as a constraint?

Thank you!

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

08-06-2015 05:14 PM

You can define explicit constraints, but this looks to me like a good place to instead use implicit variables:

impvar B {p in PSET} = A[p,**1**];

impvar C {p in PSET} = A[p,**2**];

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

08-06-2015 06:20 PM

Thanks, I tried in this way but it seems A is a 0 matrix.

May I ask how to define specific constraint?

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

08-06-2015 06:29 PM

I don't understand what is wrong with what you tried. What I suggested should work no matter what values the A variables take. If you post your code, I'll take a look.

Here's how you can define B with an explicit variable and constraint:

var B {PSET};

con Bcon {p in PSET}: B

= A[p,**1**];

You can do something similar for C.

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

08-06-2015 07:02 PM

Sorry it seems I cannot upload a file larger than 1kb.

And below is part of my code:

var rep_size_1 {PRODUCTS, STAGES2}>=0 integer;

var rep_size_12 {PRODUCTS}>=0 integer;

var rep_size_13 {PRODUCTS}>=0 integer;

constraint c1 {p in PRODUCTS}:

rep_size_12

= rep_size_1 [p,1];

constraint c2 {p in PRODUCTS}:

rep_size_13

= rep_size_1 [p,2];

With the error message:

ERROR: The array subscript 'rep_size_1[1,1]' is invalid at line 1051 column 38.

Thanks!

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

08-06-2015 07:10 PM

Evidently, STAGES2 does not contain 1. In that case, you will get the same error if you use IMPVAR.

You need to use other values for k if they are not 1 and 2.

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

08-06-2015 08:04 PM

Got it.

You are the best, Rob！