BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
JVenter4Absa
Calcite | Level 5

Hi all

 

To make matters simple, I have two equations of the form f(x) and g(x), and I would like to solve for the value of x that results in f(x) = g(x). I'm using PROC OPTMODEL where the objective is to minimize z(x)=f(x)-g(x) by changing the variable x. Obviously, the value of x that produces z(x) = 0 gives the perfect solution. However, suppose that I am satisfied if z(x) is less than or equal to some value epsilon, i.e., PROC OPTMODEL can terminate and give me the value of x as soon as z(x) <= epsilon (epsilon can be something like 0.005). How can I specify this in my PROC OPTMODEL options? My PROC OPTMODEL statement uses "min z_x = abs (f_x - g_x); solve with nlp / algorithm=interiorpoint maxiter=30;"

P.S. I note that after about 5 to 10 iterations, PROC OPTMODEL gets to a point where z(x) is really small (e.g., z(x) = 0.00001234...), but then it continues in an attempt to minimize z(x). For this reason, I've incorporated a "maxiter=30" option in the PROC OPTMODEL code.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Try
min z_x = abs (f_x - g_x);
-->
min z_x = (f_x - g_x)**2;

Which is a smooth function could get its derivatives, while abs() could not.

View solution in original post

2 REPLIES 2
Ksharp
Super User
Try
min z_x = abs (f_x - g_x);
-->
min z_x = (f_x - g_x)**2;

Which is a smooth function could get its derivatives, while abs() could not.
JVenter4Absa
Calcite | Level 5
Thank you. This does the trick!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 221 views
  • 1 like
  • 2 in conversation