[Ipopt] Initialize() and Free() in IPOPT---> RE: Ipopt Digest, Vol 38, Issue 6

ZhangWeizhong greatzwz at hotmail.com
Thu Feb 21 16:32:27 EST 2008


HI, all:
    I am stuck in the initialization  and free of the variables in IPOPT.
    Where should I put the Initialize() method? Should it be separated from  my_nlp=new DMOC_NLP() class?
    It seems that I can not define DMOC_NLP::void Initialize(){}  along with DMOC_NLP:: void get_bounds_info(){}.
    When I assign the memories in Initialize(){}, where should I free those memories? Is it in  //destructor  in dmoc_nlp.cpp?
     
    When the program is executed without valgrind, the error message is

*** glibc detected *** ./../dmoc_example: double free or corruption (out): 0x080703a0 ***

     I have searched the web,  "it means that you are calling delete on a ptr that you have already deleted"

     So the problem is concluded as the variables initialization and free in IPOPT.
     What kind of "variable initialization and free" definition structure in the whole program should I give to IPOPT?
    
     By the way, in NAG, initialize() and free() are  independent functions which are called in the main() functions.
    
     How can I call initialize() and free() in the IPOPT main function to solve the problem?   At present, my understanding of IPOPT is
by call "mynlp= new DMOC_NLP(), app= new IpoptApplication(), app->OptimizeTNLP(mynlp)" to solve the problem. Therefore most methods are defined in DMOC_NLP().  Where should I put "Initialize(), free()"  so that I can call separately from DMOC_NLP() in the main function.
    I am new to c++ programming, maybe my question is very silly, if so, I am still learning and hope that I can catch up step by step, sorry about that.

      Thank you so much.
                                        Weizhong Zhang
   

----------------------------------------
> From: greatzwz at hotmail.com
> To: ipopt at list.coin-or.org
> Subject: RE: Ipopt Digest, Vol 38, Issue 6
> Date: Wed, 20 Feb 2008 10:17:27 -0500i
> 
> 
> Hi, all:
>     I have figured it out for the initialization problem.
>     But now the error is
>  "
>     Invalid read of size 8
>     at 0x45d6ef0: DMOC_NLP::get_bounds_info(int, double*, double*, int, double*, int, doouble*, double*)
>     Address ox45d6fe4 is 4 bytes before a block of size 0 alloc'd 
>    at 0x4022F14: operator new[](unsigned) (vg_replace_malloc.c:268)"e
> 
>    I do not know why?
>    Because I have use   Initialize() to allocate the memory to  the variables in get_bounds_info()
>    The assignment is like the following
>     x_l=(double*)calloc(dim,sizeof(double).....
> 
>    Anyone can help this?
>   Thank you.
>                             Weizhong Zhang
> 
> ----------------------------------------
>> From: greatzwz at hotmail.com
>> To: ipopt at list.coin-or.org
>> Subject: RE: Ipopt Digest, Vol 38, Issue 6
>> Date: Tue, 12 Feb 2008 17:25:35 -0500
>> 
>> 
>> Hi, all
>>      Thank Dr Andreas for making it clear about "Hessian approximation".
>>      And I have used valgrind to test my program.
>> 
>>      The errors are  
>>      "Conditional jump or move depends on uninitialised value(s)"
>>      "Use of uninitialised value of size 4".
>>      "Too few degrees of freedom (n_x = 0, n_c = 104). Trying fixed_variable_treatment = RELAX_BOUNDS"
>> 
>>      My program is modified from "MyExample" from IPOPT package
>>      The main program is  "dmocexample.cpp", in which it call mynlp(mynlp= new DMOC_NLP();)
>> 
>>      The program which defines the methods such as get_nlp_info()  is called dmoc_nlp.cpp
>>      
>>     My question is
>>    " Can I initialize the variables  before "constructor" , "destructtor" and the methods in dmoc_nlp.cpp?" 
>>     Or I have to initialize the variables in different functions like "get_nlp_info()" and so on?
>> 
>>     It seems that I can not define the global variables in the main program"dmocexample.cpp" so that I do not have to define them in the "dmoc_nlp.cpp".  And even I initialized variables in "dmoc_nlp.cpp" outsides of the functions, it seems it is not successfully initialized.
>> 
>>     Anyone can give some suggestions? Thank you so much.
>>                                                                            Weizhong Zhang
>>                                                                            Electrical and Computer Engieering Dept
>>                                                                            University of Louisville             
>>     
>>    
>>       
>>      
>> 
>> 
>> 
>> ----------------------------------------
>>> From: ipopt-request at list.coin-or.org
>>> Subject: Ipopt Digest, Vol 38, Issue 6
>>> To: ipopt at list.coin-or.org
>>> Date: Mon, 11 Feb 2008 12:00:02 -0500
>>> 
>>> Send Ipopt mailing list submissions to
>>> 	ipopt at list.coin-or.org
>>> 
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> 	http://list.coin-or.org/mailman/listinfo/ipopt
>>> or, via email, send a message with subject or body 'help' to
>>> 	ipopt-request at list.coin-or.org
>>> 
>>> You can reach the person managing the list at
>>> 	ipopt-owner at list.coin-or.org
>>> 
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of Ipopt digest..."
>>> 
>>> 
>>> Today's Topics:
>>> 
>>>    1. Re: [Coin-ipopt] FW: Help on "Hessian Approximation" of my
>>>       optimization problem (Andreas Waechter)
>>> 
>>> 
>>> ----------------------------------------------------------------------
>>> 
>>> Message: 1
>>> Date: Mon, 11 Feb 2008 11:01:45 -0500 (EST)
>>> From: Andreas Waechter 
>>> Subject: Re: [Ipopt] [Coin-ipopt] FW: Help on "Hessian Approximation"
>>> 	of my optimization problem
>>> To: ZhangWeizhong 
>>> Cc: coin-ipopt at list.coin-or.org
>>> Message-ID: 
>>> Content-Type: text/plain; charset="x-unknown"
>>> 
>>> Hi,
>>> 
>>> It is correct that you don't need to overload the bool eval_h function if 
>>> you want to use the quasi-Newton option of Ipopt.
>>> 
>>> But you should not change the argument list for the get_nlp_info function 
>>> - if you do that, the Ipopt code will still try to call the original 
>>> function, and as you saw, this doesn't work since this is then a pure 
>>> virtual function, and you can't run the program.  Just set nnz_h_lag to 
>>> zero in your implementation of the original method of TNLP.
>>> 
>>> As for the segmentation fault, it probably means that there is something 
>>> wrong in the way you call Ipopt.  The easiest way to debug such memory 
>>> problems is to use a memory checker, such as the free valgrind program for 
>>> Linux.
>>> 
>>> Regards,
>>> 
>>> Andreas
>>> 
>>> 
>>> On Thu, 7 Feb 2008, ZhangWeizhong wrote:
>>> 
>>>>
>>>>     Sorry, I forgot the detailed information
>>>>     IPOPT version: 3.3.3
>>>>     My computer is i686 2.6.20-16-generic, ubuntu 7.10
>>>>
>>>>
>>>> From: greatzwz at hotmail.comTo: greatzwz at hotmail.comSubject: Help on 
>>>> "Hessian Approximation" of my optimization problemDate: Wed, 6 Feb 2008 
>>>> 16:29:04 -0500
>>>>
>>>>
>>>> Hi, friends:  Sorry to bother you.  I have one problem regarding 
>>>> "Hessian Approximation" in IPOPT application.  In the main program, the 
>>>> option is configured as "app->Options()- 
>>>> SetStringValue("hessian_approximation","limited-memory")".  It is 
>>>> indicated in the menu, I do not have to implement "bool eval_h()", so I 
>>>> commented it out in my_program.cpp and my_program.hpp.  Then my program 
>>>> can be compiled successfully, however the resulted executable program is 
>>>> not working, the error message is "Segmentation fault(core dumped)".  I 
>>>> thought maybe that I did not provide the hessian informationin the 
>>>> method "get_nlp_info(.... Index&nnz_h_lag...)". Thus I commented this 
>>>> parameter out in my_program.cpp and my_program.hpp correspondingly. 
>>>> Afterwards, I compiled the program. It still is successfully compiled. 
>>>> Now when I execute it, the error message is "pure virtual method called 
>>>> terminate called without an active exception"  I have searched the 
>>>> websit! e, it seems all the methods I used did not include itself or 
>>>> other methods which are not defined previously.Thus I do not know why 
>>>> the error indicates "pure virtual method called".  If anybody can help, 
>>>> I would appreciate that.  Thank you so much.  Weizhong Zhang> Subject: 
>>>> Welcome to the "Coin-ipopt" mailing list (Digest mode)> From: 
>>>> coin-ipopt-request at list.coin-or.org> To: greatzwz at hotmail.com> Date: 
>>>> Wed, 6 Feb 2008 16:09:16 -0500>> Welcome to the 
>>>> Coin-ipopt at list.coin-or.org mailing list!>> To post to this list, send 
>>>> your email to:>> coin-ipopt at list.coin-or.org>> General information 
>>>> about the mailing list is at:>> 
>>>> http://list.coin-or.org/mailman/listinfo/coin-ipopt>> If you ever want 
>>>> to unsubscribe or change your options (eg, switch to> or from digest 
>>>> mode, change your password, etc.), visit your> subscription page at:>> 
>>>> http://list.coin-or.org/mailman/options/coin-ipopt/greatzwz%40hotmail.com> 
>>>>>> You can also!
>>>>  make such adjustments via email by sending a message to:>> Coin-ipop
>>>>
>>>> t-request at list.coin-or.org>> with the word `help' in the subject or body (don't include the> quotes), and you will get back a message with instructions.>> You must know your password to change your options (including changing> the password, itself) or to unsubscribe. It is:>> 8686>> Normally, Mailman will remind you of your list.coin-or.org mailing> list passwords once every month, although you can disable this if you> prefer. This reminder will also include instructions on how to> unsubscribe or change your account options. There is also a button on> your options page that will email your current password to you.
>>>>
>>>> ?? Windows Live Spaces ?????????????????????????????? ??????????????
>>>> _________________________________________________________________
>>>> ?????????? MSN ????????????????????
>>>> http://mobile.msn.com.cn/
>>> 
>>> ------------------------------
>>> 
>>> _______________________________________________
>>> Ipopt mailing list
>>> Ipopt at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/ipopt
>>> 
>>> 
>>> End of Ipopt Digest, Vol 38, Issue 6
>>> ************************************
>> 
>> _________________________________________________________________
>> MSN圣诞礼物火热登场,免费发放中,快来领取吧!
>> http://im.live.cn/emoticons/?ID=18
> 
> _________________________________________________________________
> MSN圣诞礼物火热登场,免费发放中,快来领取吧!
> http://im.live.cn/emoticons/?ID=18

_________________________________________________________________
MSN圣诞礼物火热登场,免费发放中,快来领取吧!
http://im.live.cn/emoticons/?ID=18


More information about the Ipopt mailing list