## Optimization of function, not a model

Solved
Occasional Contributor
Posts: 18

# Optimization of function, not a model

Hi!

I've found a model that I want to recreate for my masters thesis but the procedure is very imprecise. Essentially what I want is to find the implied probability (p) that is needed for a model to produce a certain outcome (A). In other words i want to send in some p

p = a*x + b*y where a and b are known.

So the optimization would roughly be:

1. Chose x and y

2. Calculate p and insert into the model

3. Compare result with desired outcome A

The authors just state that they use a grid search (something which i'm not familiar with) to achieve this and nothing more.

My main question is: is it possible to optimize a model like this when I'm treating the model itself as a "black box". Since the model is fairly complicated i think that if it is not possible I would try to "manually" produce code that tries a number of combinations of x and y and find the best fitted pair... although i'd prefer if there was a more elegant and simple way to achieve this.

I'm using SAS/IML.

Accepted Solutions
Solution
‎03-15-2018 05:06 AM
SAS Super FREQ
Posts: 4,240

## Re: Optimization of function, not a model

Yes, you can do this. Optimization methods don't care how the objective function is computed, and IML will compute numerical derivatives for you for any Newton-type optimizations.

Two issues that you might encounter:

1. In your example, p is the probability that depends on a and b. You will need to set constraints on a and b so that 0< p <1.

2. You don't seem to have any randomness (for example, a regression model with "noise"), but if the objective function is stochastic then the optimization algorithm will get close to the optimal value but then will "bounce around" because of the random terms.solution.)

Some articles for you to read:

Maximum likelihood estimation in SAS/IML

Optimizing a function that evaluates an integral

Optimizing a function of an integral

All Replies
Super User
Posts: 10,770

## Re: Optimization of function, not a model

You want P be maximize or minimize or a constant value. All these could be done vi
Solution
‎03-15-2018 05:06 AM
SAS Super FREQ
Posts: 4,240

## Re: Optimization of function, not a model

Yes, you can do this. Optimization methods don't care how the objective function is computed, and IML will compute numerical derivatives for you for any Newton-type optimizations.

Two issues that you might encounter:

1. In your example, p is the probability that depends on a and b. You will need to set constraints on a and b so that 0< p <1.

2. You don't seem to have any randomness (for example, a regression model with "noise"), but if the objective function is stochastic then the optimization algorithm will get close to the optimal value but then will "bounce around" because of the random terms.solution.)

Some articles for you to read:

Maximum likelihood estimation in SAS/IML

Optimizing a function that evaluates an integral

Optimizing a function of an integral

Occasional Contributor
Posts: 18

## Re: Optimization of function, not a model

Quick follow up question: is there a way to specify the number of iterations using "nlpnra"? I couldn't find any examples of it on the SAS forums.

It's not of great importance for me to get a perfect optimization so i would like to so how good it gets after a few step. further as there are some randomness in my objective function i fear this might make it hard to find a "perfect optimal solution"

SAS Super FREQ
Posts: 4,240