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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Discussion stats
  • 2 replies
  • 1165 views
  • 1 like
  • 2 in conversation