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

i know how i can to min / max a function with proc optmodel 

 

(example here)

 

proc optmodel;
   var x,y;
   number z=-3;
   number res=8;
   min  f1 =  y+x**3 + z*y**3;
   con c1: x*y = res;
   solve with nlp;
 quit;


but i want to minimize and maximize in the same proc optmodel. I know i can do two proc optmodel like this:

 


proc optmodel;
   var x,y;
   number z=-3;
   number res=8;
   min  f1 =  y+x**3 + z*y**3;
   con c1: x*y = res;
   solve with nlp;
 quit;


proc optmodel;
   var x,y;
   number z=-3;
   number res=8;
   max  f1 =  y+x**3 + z*y**3;
   con c1: x*y = res;
   solve with nlp;
 quit;

is it possible?

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Yes, here's one way:

proc optmodel;
   var x,y;
   number z=-3;
   number res=8;
   min  f1 =  y+x**3 + z*y**3;
   con c1: x*y = res;
   solve with nlp;
   max  f2 =  y+x**3 + z*y**3;
   solve with nlp;
 quit;

In general, you can make any model changes you want and call the same solver or different solvers as many times as you want in the same PROC OPTMODEL call.

 

Several of the examples in this book illustrate this functionality.

View solution in original post

1 REPLY 1
RobPratt
SAS Super FREQ

Yes, here's one way:

proc optmodel;
   var x,y;
   number z=-3;
   number res=8;
   min  f1 =  y+x**3 + z*y**3;
   con c1: x*y = res;
   solve with nlp;
   max  f2 =  y+x**3 + z*y**3;
   solve with nlp;
 quit;

In general, you can make any model changes you want and call the same solver or different solvers as many times as you want in the same PROC OPTMODEL call.

 

Several of the examples in this book illustrate this functionality.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 756 views
  • 0 likes
  • 2 in conversation