[Ipopt] User Teminiation during the process
Stefan Vigerske
stefan at math.hu-berlin.de
Mon Apr 19 15:07:27 EDT 2010
Hi,
> Getting the x values there is not straight-forward, but possible. They
> are stored inside the const IpoptData* ip_data object (curr()->x()), but
> possible without fixded variables (if you have any). It's bit tricky to
> get there, but if you know C++ and look a bit around, you should be able
> to get the values.
The crucial point is that you need to get access to the
TNLPAdapter::ResortX function:
http://www.coin-or.org/Doxygen/Ipopt/class_ipopt_1_1_t_n_l_p_adapter.html#9d1679322cc963f1e58aed0d9416247c
That should allow you to translate from Ipopts internal representation
to the one used in the TNLP.
Andreas once suggested the following way on how to get to the
TNLPAdapter from an IpoptCalculatedQuantities object:
#include "IpTNLPAdapter.hpp"
#include "IpOrigIpoptNLP.hpp"
// 1. Use IpoptCalculatedQuantities::GetIpoptNLP() to get a pointer to
an Ipopt::IpoptNLP.
// 2. Cast this Ipopt::IpoptNLP to an Ipopt::OrigIpoptNLP
// 3. Use Ipopt::OrigIpoptNLP::nlp() to get the Ipopt::NLP
// 4. This Ipopt::NLP is actually the TNLPAdapter
TNLPAdapter* tnlp_adapter = NULL;
OrigIpoptNLP* orignlp = NULL;
if (cq)
orignlp = dynamic_cast<OrigIpoptNLP*>(GetRawPtr(cq->GetIpoptNLP()));
if (orignlp)
tnlp_adapter = dynamic_cast<TNLPAdapter*>(GetRawPtr(orignlp->nlp()));
Then something like
double* myX = new double[n];
nlp_adapter->ResortX(*cq->curr_x(), myX);
should work to get the current x in the myX array.
Stefan
>
> Andreas
>
> On Sun, 18 Apr 2010, York Tang wrote:
>
>> Hi,
>>
>> In this intermediate callback function, how can i obtain the current
>> "x" (variables) ?
>> Thank you.
>>
>> York
>>
>>
>> 2010/4/16 Stefan Vigerske <stefan at math.hu-berlin.de>:
>>> Hi,
>>>
>>>> Because I want to add an active set mechanism with ipopt. It means i
>>>> want to keep trace on each iteration of ipopt.
>>>> At the beginning, I provide some basic constraints, then if I
>>>> identified one iteration which do not follow some "extra" constraints
>>>> (which have not added to the optimization yet), then i will add that
>>>> constraint during the process (save the current points, end the
>>>> current optimization, and start a new optimization with new added
>>>> constraints and the saved current iteration points).
>>>> The idea is to lower the number of constraints in my system.
>>>>
>>>> Does anyone have any experience on it? (Can it be implemented with
>>>> ipopt? Do it help the optimization (speed or result)?)
>>>
>>> Problem may be that it may not be possible to efficiently warmstart
>>> Ipopt after you added a constraint.
>>>
>>>> Also, if there exist a user request termination functions in ipopt? If
>>>> I just end the ipopt process manually (with my coding), will it cause
>>>> some memory problem?
>>>
>>> You should use the intermediate callback function to interrupt Ipopt,
>>> see http://www.coin-or.org/Ipopt/documentation/node46.html and
>>> http://www.coin-or.org/Doxygen/Ipopt/class_ipopt_1_1_t_n_l_p.html#2f962a4c43464adb7928771af84503d6
>>>
>>> That way, there should be no memory problem.
>>>
>>> Stefan
>>>
>>
>> _______________________________________________
>> Ipopt mailing list
>> Ipopt at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/ipopt
>>
>>
>
--
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan
More information about the Ipopt
mailing list