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

max z  = 3x[1] + 3x[2]

s.t.    x[1] + x[2] <=1;

         All x[i] =>0

 

What would the general code be?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Yeah. Post it at OR forum. @RobPratt  is there .

 

proc optmodel;
var x1>=0 ,x2>=0;
max z=3*x1+3*x2;
con a:x1+x2<=1;
solve  with lp;
print x1 x2;
quit;

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

Welcome to the SAS Forum!

 

Finding ONE optimal solution can be done with proc optmodel (part of SAS/OR, which requires a separate licence) using the SOLVE WITH LP statement, see example here. Adding some other constraint (such as x[1] and x[2] integers) would be required to make the set of ALL optimal solutions finite, in which case you would use SOLVE WITH CLP to find all solutions.

 

Posting your questions to the OR Community would reach experts in those procs.

PG
RobPratt
SAS Super FREQ

In SAS Optimization 8.4 to be released soon, you can also find all optimal solutions with the MILP solver, which allows both integer and non-integer variables.  For that purpose, two solutions are considered distinct if they differ for some integer variable.

Ksharp
Super User

Yeah. Post it at OR forum. @RobPratt  is there .

 

proc optmodel;
var x1>=0 ,x2>=0;
max z=3*x1+3*x2;
con a:x1+x2<=1;
solve  with lp;
print x1 x2;
quit;
RobPratt
SAS Super FREQ

@Ksharp's code looks good for finding one optimal solution.  For LP, the number of optimal solutions can be 0, 1, or infinite.  In your example, the entire line segment from (x1,x2) = (1,0) to (0,1) is optimal.  The LP solver returns only one of these solutions.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1279 views
  • 0 likes
  • 4 in conversation