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

hi,

I am trying to solve the following problem

1main.JPG

I mean I want to minimize the function f(x).

I have written the following code (without the FIX commands)

proc optmodel;
var x1, x2 , x3;
min f = x1^2 + 2*(x2^2) + 5*(x3^2) -4*x1 -20*x2 -20*x3;
/* starting point */
x1 = 0;
x2 = 0;
x3 = 0;
solve; 
print x1 x2 x3 x1.dual x2.dual x3.dual;
quit;

and I get the following result

1nofix.JPG

There are no values for the dual but I get the value of objective function

But when I write the same code with fix commands (as given below).

 

proc optmodel;
var x1, x2 , x3;
min f = x1^2 + 2*(x2^2) + 5*(x3^2) -4*x1 -20*x2 -20*x3;
/* starting point */
fix x1 = 0;
fix x2 = 0;
fix x3 = 0;
solve; 
print x1 x2 x3 x1.dual x2.dual x3.dual;
quit;

then i get the following result

1fix.JPG+

now there are no values for the 3 variables and also no value for the objective function

Sorry I dont know exactly the function of "FIX" command.

Please can you explain the purpose of "FIX" command here.

Which code should I use to solve this problem?

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

The FIX statement fixes variables to the specified values.  If you want to minimize the function, don't fix anything, and the solver will find optimal values for the variables.  At a locally optimal solution, the dual values will be 0.  But to find the gradient at a given solution, you must fix the variables.  The resulting dual values (gradient) indicate the direction of steepest descent.  As you did in other questions, you would proceed with a line search to find the best step length alpha in that direction.

View solution in original post

1 REPLY 1
RobPratt
SAS Super FREQ

The FIX statement fixes variables to the specified values.  If you want to minimize the function, don't fix anything, and the solver will find optimal values for the variables.  At a locally optimal solution, the dual values will be 0.  But to find the gradient at a given solution, you must fix the variables.  The resulting dual values (gradient) indicate the direction of steepest descent.  As you did in other questions, you would proceed with a line search to find the best step length alpha in that direction.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 655 views
  • 0 likes
  • 2 in conversation