[Ipopt] Problems in models in C++/ Initialization does not succeed

Dan yanndan at yahoo.com
Thu Feb 10 08:10:58 EST 2011


Dear all,
Thanks to all ideas, I was successful in attempt to retrieve my bug. As often, the bug stands between the chair and the keyboard. When I was evaluating my constraint (function eval_g), I had this kind of loop for the ith constraint:
for (int j = 0; j < ...; ++j){    g[i]+= something(i);}
The mistake was to not initialized g[i] to 0 before adding expressions. So the solution was to  write g[i]=0for (int j = 0; j < ...; ++j){    g[i]+= something(i);}


I can also outline that Code::Blocks throws exceptions or errors that do not appear while using command line or valgrind. If it can help other people.
Thanks again for evertyhing, it was really really helpful to me.
Best regards,Dan
--- En date de : Mer 9.2.11, Hans Pirnay <hans.pirnay at rwth-aachen.de> a écrit :

De: Hans Pirnay <hans.pirnay at rwth-aachen.de>
Objet: Re: [Ipopt] Problems in models in C++/ Initialization does not succeed
À: "Dan" <yanndan at yahoo.com>
Cc: ipopt at list.coin-or.org
Date: Mercredi 9 février 2011, 14h37

Dan,
you seem to define an option called "jacobian" somewhere. Is there a file "ipopt.opt" in the directory you are executing the problem in? Ipopt will look for a file with that name and try to read option definitions from it. If there is such a file, move/rename it.

About your jacobian: With the option  app->Options()->SetStringValue( "jacobian_approximation","finite-difference-values" );
you let Ipopt construct the jacobian from finite differences. Any code in your Ipopt::TNLP::eval_jac_g implementation will not be called. Try commenting all options except for the derivative checker.

If you are just running a model, it is generally a better idea to define the options in the separate ipopt.opt file - that way you don't have to recompile your problem just to change the parameters or turn the derivative checker off. Read about it here: http://www.coin-or.org/Ipopt/documentation/node55.html
If you read options from a file, make absolutely sure, that there is a new line at the end of the file. 
hope this helps

Hans

On Wed, Feb 9, 2011 at 2:01 PM, Dan <yanndan at yahoo.com> wrote:

Thank you Hans for your answer.

I am running this program under ubuntu 10.04 coding with CodeBlocks 8.02.I tried your idea of using Valgrind. Code::Blocks does not seem to redirect all the printings to the terminal.  Thanks to valgrind, I was able to see an error message I was missing for a long time.
:**********************************************************************Exception of type: OPTION_INVALID in file
 "../../../../Ipopt/src/Common/IpOptionsList.cpp" at line 638: Exception message: Read Option: "jacobian". It is not a valid option. Check the list of available options.


*** Error during initialization!
*********************************************************************
This error seems to come from the piece of code below. I now have an exit error if initialization does not suceed. It is strange this error occurs in this code. 

When I coded my example in hs_071 way, the same piece of code does not return any error.
***********************************************************************
// Create an instance of the IpoptApplication
//// We are using the factory, since this allows us to compile this// example with an Ipopt Windows DLL
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
// Change some options
// Note: The following choices are only examples, they might not be//       suitable for your optimization problem.app->Options()->SetNumericValue("tol", 1e-7);
app->Options()->SetStringValue("mu_strategy", "adaptive");app->Options()->SetStringValue("output_file", "ipopt.out");
app->Options()->SetStringValue(
 "jacobian_approximation","finite-difference-values" );app->Options()->SetStringValue( "derivative_test","first-order" );

// Intialize the IpoptApplication and process the optionsApplicationReturnStatus status;
status = app->Initialize();if (status != Solve_Succeeded) {printf("\n\n*** Error during initialization!\n");
exit(-1);}
*******************************************************************************************

I do not understand why there is an initialization problem in this case. I run valgrind to see if there was any memory leak. The code previous at this step of initialization  does not seem to have any. 

If you have any idea how to solve this initialization bug, I will be glad to know them.

Best Regards, Dan



--- En date de : Mer 9.2.11, Hans Pirnay <hans.pirnay at rwth-aachen.de> a écrit :


De: Hans Pirnay <hans.pirnay at rwth-aachen.de>

Objet: Re: [Ipopt] Problems in models in C++
À: "Dan" <yanndan at yahoo.com>
Cc: ipopt at list.coin-or.org

Date: Mercredi 9 février 2011, 11h37

If you are on linux: use valgrind to figure out if your problems may be due to uninitialized values

On Wed, Feb 9, 2011 at 10:57 AM, Dan <yanndan at yahoo.com> wrote:


Dear all,


I have a problem with the C++ Interface. I am currently coding some network models. I tried to model a small instance like the hs_071 example and it went well.


I coded my network in term of functions that my TNLP class will called if needed.  

When I run it, it does not find a solution and it goes into a loop.I caught this message run by IPOPT:"WARNING : Problem in step computation; switching to emergency code."


In order to solve my problem, I tried several thing including the derivative checker and two weird things appears:

my jacobian is not dense. I can not figure why. I checked at almost step and I can not find why the derivative checker of my jacobian is dense.the value found by the derivative checker are eccentric. It says mine are wrong while they are not. It is a adjacency matrix so it is only 1 and -1.

If you have any ideas to solve my problem of ways to find my errors, I would greatly appreciate.
Best
 Regards,Dan





      

_______________________________________________

Ipopt mailing list

Ipopt at list.coin-or.org

http://list.coin-or.org/mailman/listinfo/ipopt










      
_______________________________________________

Ipopt mailing list

Ipopt at list.coin-or.org

http://list.coin-or.org/mailman/listinfo/ipopt







      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/ipopt/attachments/20110210/6401307a/attachment.html 


More information about the Ipopt mailing list