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 question

Capture.JPG

 

I have written the following code for this

proc optmodel;
var x, y,z;
min f = 4*(x^2+y-z)^2 + 10;
/* starting point */
   x = 1;
   y = 1;
   z=1;
solve; 
print x y z x.dual y.dual z.dual;
quit;

Now if P is the descent direction of f at Xo then

I need to find the minimizer Aplha for this problem

I mean to say that I am trying to solve this question:

Capture.JPG

I dont see Alpha in the output.

Please can someone help me find the value of Alpha which is the minimizer

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

To find the descent direction from the initial point, you need to fix the values of the variables and then take the negative gradient.  To find the best step size alpha in that direction, you can solve an auxiliary one-variable problem.  The following code implements these ideas, where I have renamed the original variables x[1], x[2], and x[3].

 

proc optmodel;
   num n = 3;
   var x {1..n} init 1;
   min f = 4*(x[1]^2+x[2]-x[3])^2 + 10;
   fix x;
   solve; 
   print x x.dual;

   num p {1..n};
   for {j in 1..n} p[j] = -x[j].dual;
   var alpha >= 0;
   min g = 4*((x[1]+alpha*p[1])^2+(x[2]+alpha*p[2])-(x[3]+alpha*p[3]))^2 + 10;
   solve; 
   print alpha;
quit;

 

View solution in original post

5 REPLIES 5
RobPratt
SAS Super FREQ

To find the descent direction from the initial point, you need to fix the values of the variables and then take the negative gradient.  To find the best step size alpha in that direction, you can solve an auxiliary one-variable problem.  The following code implements these ideas, where I have renamed the original variables x[1], x[2], and x[3].

 

proc optmodel;
   num n = 3;
   var x {1..n} init 1;
   min f = 4*(x[1]^2+x[2]-x[3])^2 + 10;
   fix x;
   solve; 
   print x x.dual;

   num p {1..n};
   for {j in 1..n} p[j] = -x[j].dual;
   var alpha >= 0;
   min g = 4*((x[1]+alpha*p[1])^2+(x[2]+alpha*p[2])-(x[3]+alpha*p[3]))^2 + 10;
   solve; 
   print alpha;
quit;

 

rohailk
Obsidian | Level 7

thank you so much for your answer @RobPratt 

Just one more question.I am trying to re write your program for the following problem.

Capture.JPG

 min f = (x[1]-2)**4 + (x[1]-2*x[2])**2;

Sorry I am new to sas .Please can you help me write the same code as that in your answer for this new problem to calculate alpha.I tried but each time I tried I got alpah=0 and a an error message also

Thanks

RobPratt
SAS Super FREQ

Here's how I would do it:

proc optmodel;
   num n = 2;
   var x {1..n};
   min f = (x[1]-2)**4 + (x[1]-2*x[2])**2;
   fix x[1] = 0;
   fix x[2] = 3;
   solve; 
   print x x.dual;

   num p {1..n};
   for {j in 1..n} p[j] = -x[j].dual;
   var alpha >= 0;
   min g = (x[1]+alpha*p[1]-2)**4 + (x[1]+alpha*p[1]-2*(x[2]+alpha*p[2]))**2;
   solve;
   print alpha;
quit;

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1043 views
  • 0 likes
  • 3 in conversation