Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

find a vector solution from two constraints

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

find a vector solution from two constraints

Hi All,

 

I used SAS/OR proc optmodel before in order to find a solution. But that's for a single number.

Now I need to randomly pick 100 records from 1000 records. There is another constaint, the sum of these 100 records must be a ceterain number (K).

 

So the constaints are: sum of the total number of records is 100 and the sum of records is K.

 

Where can I start? I look up some of examples but I cannot find anything similar.

 

Thanks

 


Accepted Solutions
Solution
‎07-05-2017 09:13 AM
SAS Employee
Posts: 433

Re: find a vector solution from two constraints

I think you want to declare a binary variable for each record and then declare your two constraints, like this:

set RECORDS;
num a {RECORDS};
read data indata into RECORDS=[record] a;
var X {RECORDS} binary;
con NumberRecords:
   sum {r in RECORDS} X[r] = 100;
con SumRecords:
   sum {r in RECORDS} a[r]*X[r] = k;

View solution in original post


All Replies
Solution
‎07-05-2017 09:13 AM
SAS Employee
Posts: 433

Re: find a vector solution from two constraints

I think you want to declare a binary variable for each record and then declare your two constraints, like this:

set RECORDS;
num a {RECORDS};
read data indata into RECORDS=[record] a;
var X {RECORDS} binary;
con NumberRecords:
   sum {r in RECORDS} X[r] = 100;
con SumRecords:
   sum {r in RECORDS} a[r]*X[r] = k;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 289 views
  • 1 like
  • 2 in conversation