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

Hello everyone,

 

I would like to initialize the values of my parameters x1 and x2, by picking them from a table. My table nr has two variables x1 and x2, with one value for each.

My objective function is a function that I have defined in a previous proc fcmp.

 

proc nlp tech=NEWRAP invar=two(type=PARMS) gradcheck=detail gconv2=1e12 ;
min f;
decvar x1 x2;
f = (1-x1)*2+100(x2-x1*2)*2;
run;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You can use the INEST= data set to specify initial values for the decision variables. 

data Two(type=EST);
_TYPE_ = "PARMS";
input x1 x2;
datalines;
 1 2
-1 -1 
 1 0
;


proc nlp tech=NEWRAP invar=two gradcheck=detail gconv2=1e12 ;
min f;
decvar x1 x2;
f = (1-x1)**2+100*(x2-x1**2)**2;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

You can use the INEST= data set to specify initial values for the decision variables. 

data Two(type=EST);
_TYPE_ = "PARMS";
input x1 x2;
datalines;
 1 2
-1 -1 
 1 0
;


proc nlp tech=NEWRAP invar=two gradcheck=detail gconv2=1e12 ;
min f;
decvar x1 x2;
f = (1-x1)**2+100*(x2-x1**2)**2;
run;
ChanceTGardener
SAS Employee

If you wanted to go the OPTMODEL route. 

 

data Two;
input x1 x2;
datalines;
 1 2
-1 -1 
 1 0
;

proc optmodel;

set <num> INIT;

num x1_init{INIT};
num x2_init{INIT};

read data Two into INIT=[_N_] x1_init=x1 x2_init=x2;

num iter;
num optimal_x1{INIT};
num optimal_x2{INIT};
num optimal_f{INIT};

*print x1_init x2_init;

var x1{i in INIT} init x1_init[i];
var x2{i in INIT} init x2_init[i];

min f = (1-x1[iter])**2+100*(x2[iter]-x1[iter]**2)**2;

do iter=1 to card(INIT);
 solve with nlp;
  for {i in INIT: iter=i} do;
    optimal_x1[i] = x1[i].sol;
    optimal_x2[i] = x2[i].sol;
    optimal_f[i] = f.sol;
  end;
end;

create data results from [scenario]=INIT x1_init x2_init optimal_x1 optimal_x2 optimal_f;

quit;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 617 views
  • 2 likes
  • 3 in conversation