BookmarkSubscribeRSS Feed
JED
Calcite | Level 5 JED
Calcite | Level 5

Hi,

 

I don’t have much experience in using proc optmodel. I try to optimize rather complex function f. See below and it is just part of it. I wonder if there is a way to simplify it notation. In general, I would like to know if I deal with min of function z(a,b,c)=(k(a,b,c) – g(a,b,c))^3-sin(g(a,b,c)). Can I define first function k and g  and then search for min z(a,b,c) and refer to functions f and g?

 

Thank you in advance!

 

Regards,

JED

 

 

data bard;

set lib1.test;

C_T=Sigma_hat*sqrt(T)*F_hat/sqrt(2*3.14159265359*2);

Ln_F_hat=log(F_hat);

drop obs;

run;

 

 

proc optmodel;

   set J = 1..60;

   set I = 1..16;

   number T, F_hat, Sigma_hat, C_T, Ln_F_hat;

   read data bard into T F_hat Sigma_hat C_T Ln_F_hat;

    number v{k in J} = F_hat;

quit;

 

 

proc optmodel;

   set J = 1..60;

   set I = 1..16;

   number T, F_hat, Sigma_hat, C_T, Ln_F_hat;

   read data bard into T F_hat Sigma_hat C_T Ln_F_hat;

   number v0{k in J} = T;

   number v1{k in J} = F_hat;

               number v2{k in I} = Sigma_hat;

               number v3{k in I} = C_T;

    number v4{k in J} = Ln_F_hat;

  var kappa init 0.8541;

  var chi_0 init 1.8373;

  var chi_1 init 2.02;

  var mu_psi init -0.0593;

  var sigma_chi init 0.4069;

  var sigma_psi init 0.00000216;

  var rho_chi_psi init 0.000001;

  var rho init 0.00647;

  var psi init 2.200;

min f=sum{k in J}

(  psi +EXP(-1*kappa*v0[k])*chi_0 +(1-EXP(-1*kappa*v0[k]))*chi_1+mu_psi*v0[k]+0.5*((1-EXP(-2*kappa*v0[k]))*(sigma_chi^2)/(2*kappa)+(sigma_psi^2)*v0[k]+2*(1-EXP(-1*kappa*v0[k]))*((rho_chi_psi*sigma_psi*sigma_chi)/kappa))-v4[k]  )**2;

con c1: sigma_chi>=0;

con c2: sigma_psi>=0;

con c3: -1<=rho_chi_psi<=1; 

SOLVE WITH NLPC;

   print kappa;

  print  chi_0 ;

print chi_1 ;

print mu_psi;

print sigma_chi;

print sigma_psi ;

print  rho_chi_psi;

print rho ;

print psi;

print f;

quit;


data bard;
set lib1.test;
C_T=Sigma_hat*sqrt(T)*F_hat/sqrt(2*3.14159265359*2);
Ln_F_hat=log(F_hat);
drop obs;
run;


proc optmodel;
set J = 1..60;
set I = 1..16;
number T, F_hat, Sigma_hat, C_T, Ln_F_hat;
read data bard into T F_hat Sigma_hat C_T Ln_F_hat;
number v{k in J} = F_hat;
quit;


proc optmodel;
set J = 1..60;
set I = 1..16;
number T, F_hat, Sigma_hat, C_T, Ln_F_hat;
read data bard into T F_hat Sigma_hat C_T Ln_F_hat;
number v0{k in J} = T;
number v1{k in J} = F_hat;
number v2{k in I} = Sigma_hat;
number v3{k in I} = C_T;
number v4{k in J} = Ln_F_hat;
var kappa init 0.8541;
var chi_0 init 1.8373;
var chi_1 init 2.02;
var mu_psi init -0.0593;
var sigma_chi init 0.4069;
var sigma_psi init 0.00000216;
var rho_chi_psi init 0.000001;
var rho init 0.00647;
var psi init 2.200;
min f=sum{k in J}
( psi +EXP(-1*kappa*v0[k])*chi_0 +(1-EXP(-1*kappa*v0[k]))*chi_1+mu_psi*v0[k]+0.5*((1-EXP(-2*kappa*v0[k]))*(sigma_chi^2)/(2*kappa)+(sigma_psi^2)*v0[k]+2*(1-EXP(-1*kappa*v0[k]))*((rho_chi_psi*sigma_psi*sigma_chi)/kappa))-v4[k] )**2;
con c1: sigma_chi>=0;
con c2: sigma_psi>=0;
con c3: -1<=rho_chi_psi<=1;
SOLVE WITH NLPC;
print kappa;
print chi_0 ;
print chi_1 ;
print mu_psi;
print sigma_chi;
print sigma_psi ;
print rho_chi_psi;
print rho ;
print psi;
print f;
quit;

 

1 REPLY 1
RobPratt
SAS Super FREQ

Yes, you can use the IMPVAR statement to define expressions that you can reference later, including in an objective declaration.

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
  • 938 views
  • 0 likes
  • 2 in conversation