I want to know the result of each iteration of the independent variable and the target value. How can I get this information?

Hi there!

Since this is your first post, please read Please read: make it easier to help you.

However in general, there is no way to get this information. JuMP provides only the final optimal solution (if one exists).

Some solvers may support writing their progress to a log file. You should consult each solvers documentation for appropriate solver-specific parameters.

**Edit: see post below**

An easy way would be to print/record the values of the variables within the objective function. Each time it will be evaluated, you’ll have access to the values of the variables:

```
function objective(x)
objective_value = ...
println("Variables: ", x)
println("Objective value: ", objective_value)
return objective_value;
end
```

Of course, if the solver performs inner iterations to find an acceptable point (e.g. a line search), you will print/record all these points that ultimately will be discarded.

To clarify for future readers: the above post works for something like GitHub - JuliaNLSolvers/Optim.jl: Optimization functions for Julia, but not for JuMP.

JuMP works differently so you don’t define a Julia function `objective(x)`

. (There is one exception: user-defined nonlinear objective functions. But this is not a general solution.)

In general, there is no way to record the optimization process from JuMP because JuMP just *formulates* the problem, and hands off the solution of that problem to an external solver, which is often written in C/C++.

True thing! I read the original post too quickly, my bad.