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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Discussion stats
  • 4 replies
  • 1823 views
  • 0 likes
  • 4 in conversation