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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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