BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

I know some on Solver/EXCEL. New to SAS/OPTMODEL. 

Anyone can help me on this?!

I have two datasets(4 Entities, 2 States(exclusive), 2 performance measurements/State/Entity). How to find the max sum of cross product?!

Dataset1                                                    

State    E1      E2     E3      E4        E5             

S1        5.2     5.8    8.2      3.1       7.2            

S2        8.1     3.6    5.0      4.9       1.8            

Dataset2 

State   E1    E2    E3    E4      E5  

S1       2.3   3.1    9.1   7.3     4.0 

S2       4.2   5.3    7.1   4.7      7.3

Thanks   

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Not quite sure I understand, but does the following do what you want?

%let numEntities = 5;
data indata;
   input dataset state $ e1-e&numEntities;
   datalines;
1 S1 5.2 5.8 8.2 3.1 7.2
1 S2 8.1 3.6 5.0 4.9 1.8
2 S1 2.3 3.1 9.1 7.3 4.0 
2 S2 4.2 5.3 7.1 4.7 7.3
;

proc optmodel;
   set DATASETS;
   read data indata into DATASETS=[dataset];

   set <str> STATES;
   read data indata into STATES=[state];

   set ENTITIES = 1..&numEntities;
   num performance {DATASETS, STATES, ENTITIES};
   read data indata into [dataset state] {entity in ENTITIES} <performance[dataset,state,entity]=col('e'||entity)>;

   var IsState {ENTITIES, STATES} binary;

   max Objective = sum {e in ENTITIES, s in STATES} (prod {d in DATASETS} performance[d,s,e]) * IsState[e,s];

   con OneStatePerEntity {e in ENTITIES}:
      sum {s in STATES} IsState[e,s] = 1;

   for {e in ENTITIES, s in STATES: min {d in DATASETS} performance[d,s,e] < 2} fix IsState[e,s] = 0;

   solve;

   print IsState;
   print {e in ENTITIES, s in STATES: IsState[e,s].sol > 0.5} (prod {d in DATASETS} performance[d,s,e]);
quit;

View solution in original post

4 REPLIES 4
RobPratt
SAS Super FREQ

Which numbers are input, and which are output (decision variables)?  What are the restrictions on the decision variables?  Without any restrictions (constraints), the sum of cross products can be as large as you want.

hellohere
Pyrite | Level 9

Rob:

 

The variables are binary(0/1) for each entity [either state1 or state 2]. S(i), S stands for State to Entity(i). 

The goal is to maximize the sum of entity performance(two performance measurements, the product as the final performance.

     Say Performance A is the project performance; Performance B is the leadership performance.

    Entity(1)'s performance for State(1) is 5.2*2.3; for State(2) is 8.1*4.2. The goal the to maximize the team's performance. 

 

The constraints for

1) binary exclusive input, 1/0

2) performance measurement cannot be below a threshold 2.0. Entity(4) performance A on State(2) are 1.8 below the threshold 2.0,

                 then Entity(4) must not be on State(2) , Entity(4) must be on State(1). 

 

Could you help me on this?!

 

 

RobPratt
SAS Super FREQ

Not quite sure I understand, but does the following do what you want?

%let numEntities = 5;
data indata;
   input dataset state $ e1-e&numEntities;
   datalines;
1 S1 5.2 5.8 8.2 3.1 7.2
1 S2 8.1 3.6 5.0 4.9 1.8
2 S1 2.3 3.1 9.1 7.3 4.0 
2 S2 4.2 5.3 7.1 4.7 7.3
;

proc optmodel;
   set DATASETS;
   read data indata into DATASETS=[dataset];

   set <str> STATES;
   read data indata into STATES=[state];

   set ENTITIES = 1..&numEntities;
   num performance {DATASETS, STATES, ENTITIES};
   read data indata into [dataset state] {entity in ENTITIES} <performance[dataset,state,entity]=col('e'||entity)>;

   var IsState {ENTITIES, STATES} binary;

   max Objective = sum {e in ENTITIES, s in STATES} (prod {d in DATASETS} performance[d,s,e]) * IsState[e,s];

   con OneStatePerEntity {e in ENTITIES}:
      sum {s in STATES} IsState[e,s] = 1;

   for {e in ENTITIES, s in STATES: min {d in DATASETS} performance[d,s,e] < 2} fix IsState[e,s] = 0;

   solve;

   print IsState;
   print {e in ENTITIES, s in STATES: IsState[e,s].sol > 0.5} (prod {d in DATASETS} performance[d,s,e]);
quit;
hellohere
Pyrite | Level 9

Thanks a huge. It is. I verify with puppy Sovler/Excel, though hard to digest in SAS yet. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

Discussion stats
  • 4 replies
  • 911 views
  • 0 likes
  • 2 in conversation