[Ipopt] Runtime modification of the model

Stefan Vigerske stefan at math.hu-berlin.de
Sun Feb 27 12:34:05 EST 2011


maybe look at something like http://www.cplusplus.com/doc/tutorial 
first... :-)

What's the problem of storing the value of b in your TNLP object and 
accessing it during eval_f?


Am 27.02.2011 18:21, schrieb Paul Smith:
> On Sun, Feb 27, 2011 at 4:57 PM, Horand Gassmann<Horand.Gassmann at dal.ca>  wrote:
>>> Thanks, Horand, for your reply. I understand that Ipopt can solve, in
>>> the same C++ program, a bunch of optimization problems if one knows
>>> the full details of the model before we run it -- one can feed the
>>> program through files or through user interaction, as you correctly
>>> suggest. However, in my case, the details of the model cannot be known
>>> before the C++ program runs, as the parameters and the number of
>>> constraints and variables are determined while the program is running
>>> (the number of variables, the number of constraints, etc., depend on
>>> random number generated, during execution, by the C++ program).
>>> Moreover, the structure of the current model (in the current iteration
>>> of the loop) also depends on the solution of the model solved in the
>>> previous loop iteration. Thus, what I am needing is to implement is
>>> the following program flow:
>>>   1. Clear the model;
>>>   2. Generate some random numbers;
>>>   3. Calculate the structure of the new model according to the random
>>> numbers generated in 2 and according to the solution obtained for the
>>> model solved in the previous loop iteration;
>>>   4. Setup the model according to the structure calculated in the previous
>>> step;
>>>   5. Solve the model;
>>>   6. Save the solution of model;
>> Right. So what's the problem? Doing it this way, it makes no difference
>> whether the problem you solve is deterministic or stochastic. You get the
>> problem dimensions, then you populate the TNLP object, and off you go.
>> Presumably you know how to do that with fixed problem dimensions; the
>> stochastic part should be straighforward. You generate the model and data
>> /before/ you set up the instance.
> Thanks, Horand. The issue is how to populate the TNLP object.
> According to the Ipopt examples, we need to write the following
> methods:
>      * Method get_nlp_info
>      * Method get_bounds_info
>      * Method get_starting_point
>      * Method eval_f
>      * Method eval_grad_f
>      * Method eval_g
>      * Method eval_jac_g
>      * Method eval_h
>      * Method finalize_solution
> It seems to me that one needs to know in advance the structure of the
> model to write theses methods. For instance, suppose that one wants to
> write the method eval_f for the following objective function:
> x^2 + b y^3,
> with b being extracted from an uniform distribution. How could one
> write the eval_f method?
> But perhaps there a different way of populating the TNLP object that I
> am now aware of.
> Paul
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt

More information about the Ipopt mailing list