[Ipopt] Runtime modification of the model

Paul Smith phhs80 at gmail.com
Sun Feb 27 11:42:47 EST 2011


On Sun, Feb 27, 2011 at 3:44 PM, Horand Gassmann <Horand.Gassmann at dal.ca> wrote:
>> But how can one implement the methods of the TNLP class if what is to
>> be implemented can only be known at runtime?
>
> What do you mean by 'at runtime'? Presumably you have a program flow that
> goes something like this:
>
> Start the program
> Set a number of arrays
> Populate the instance
> Call the solver
> Process results
> The end
>
> If you need to get parameter values, you can read them from files, or prompt
> for user input or whatnot prior to
>
> Set a number of arrays
>
> and obviously you can place steps 2-5 inside a loop. I let you work out the
> details.
>
> What Andreas has been telling you is that once you
>
> Call the solver
>
> you cannot make any further modifications to that particular instance.

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:

LOOP BEGIN
  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;
LOOP END

Best regards, Paul



More information about the Ipopt mailing list