Changes between Version 2 and Version 3 of sIpopt


Ignore:
Timestamp:
Apr 14, 2011 1:49:48 PM (9 years ago)
Author:
rln
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • sIpopt

    v2 v3  
    1010
    1111
     12== Installation ==
     13
     14The first step to install the software is to install the trunk version of IPOPT, once this is done installing
     15sIPOPT is very simple. IPOPT’s installation instructions can be found in the IPOPT [http://www.coin-or.org/Ipopt/documentation/ documentation].
     16Also note that in the following we refer to $IPOPT as the main folder, where the !Ipopt/, !ThirdParty/,
     17!BuildTools/, . . . , folders are located.
     18
     19If you wish to use the AMPL interface, make sure that your IPOPT
     20installation also includes it. To do this you need to download the ASL library, with the get.ASL script
     21located in $IPOPT/ThirdParty/ASL.
     22
     23Finally, we assume that you created a build folder to install IPOPT in $IPOPT/build/. In this case, to download the trunk version of IPOPT you would type:
     24
     25{{{ 
     26  $ svn co https://projects.coin-or.org/svn/Ipopt/trunk $IPOPT
     27}}}
     28
     29Once IPOPT has been compiled and installed, we can proceed to build sIPOPT. To do this go to the
     30$IPOPT/build/Ipopt/contrib/sIPOPT/ folder, and type make there.
     31
     32{{{
     33  $ cd $IPOPT/build/Ipopt/contrib/sIPOPT
     34  $ make
     35}}}
     36
     37If no errors are shown after compilation you can proceed to install the libraries and to generate the
     38AMPL executable. To do this type
     39
     40{{{  $ make install }}}
     41
     42This should copy the generated libraries (libsipopt.*) to $IPOPT/build/lib, and the AMPL executable (ipopt_sens) to $IPOPT/build/bin/.
     43
     44
     45== Example ==
     46
     47To illustrate the use of the toolbox we solve the following NLP
     48
     49{{{
     50  min x1^2 + x2^2 + x3^2
     51  st
     52    6x1 + 3x2 + 2x3 − p1 = 0
     53    p2 x1 + x2 − x3 − 1 = 0
     54    x1 , x2 , x3 ≥ 0,
     55}}}
     56
     57and we perturb the parameters p1 and p2 from pa^T^ = [p1 p2] = [5 1] to pb^T^ = [4.5 1]. For this case the AMPL code is shown below.
     58
     59{{{
     60reset ;
     61
     62# Suffixes for sensitivity update
     63suffix sens_state_0, IN;
     64suffix sens_state_1, IN;
     65suffix sens_state_value_1, IN;
     66suffix sens_sol_state_1, OUT;
     67suffix sens_init_constr, IN;
     68
     69# Original value of parameters
     70param et1p ;
     71param et2p ;
     72
     73# Original parameter values
     74let et1p := 5 ;
     75let et2p := 1 ;
     76
     77# Define variables, with bounds and initial guess
     78var x1 >= 0, := 0.15 ;
     79var x2 >= 0, := 0.15 ;
     80var x3 >= 0, := 0.00 ;
     81
     82# Artificial variables so IPOPT sees the parameters
     83var et1 ;
     84var et2 ;
     85
     86# objective function
     87minimize objf: x1^2 + x2^2 + x3^2 ;
     88
     89# constraints
     90subject to
     91
     92r1: 6*x1 + 3*x2 + 2*x3 - et1 = 0 ;
     93r2: et2*x1 + x2 - x3 - 1 = 0 ;
     94
     95# Artificial constraints to pass parameters to IPOPT
     96r3: et1 = et1p ;
     97r4: et2 = et2p ;
     98
     99# Define solver and Ampl options in this case we don't want Ampl's
     100# presolve to accidentally remove artificial variables.
     101options solver ipopt_sens ;
     102option presolve 0;
     103
     104# define an order to the parameters that will change.
     105# In step 0, only et1 changes, and has position 1
     106let et1.sens_state_0 := 1 ;
     107
     108# in the first step/change et1 has position 1
     109let et1.sens_state_1 := 1 ;
     110
     111# Perturbed value of parameter et1 (in step 1)
     112let et1.sens_state_value_1 := 4.5 ;
     113
     114# In step 0, et2 has position 1
     115let et2.sens_state_0 := 2 ;
     116
     117# in the first step/change et1 has position 2
     118let et2.sens_state_1 := 2 ;
     119
     120# Perturbed value of parameter et2 (in step 1)
     121let et2.sens_state_value_1 := 1 ;
     122
     123# Artificial constraints
     124let r3.sens_init_constr := 1 ;
     125let r4.sens_init_constr := 1 ;
     126
     127# solve problem
     128solve ;
     129
     130#**********************************************
     131# Print nominal solution and bound multipliers
     132#**********************************************
     133display x1, x2, x3, et1, et2 ;
     134display x1.ipopt_zU_out, x2.ipopt_zU_out, x3.ipopt_zU_out,
     135        et1.ipopt_zU_out, et2.ipopt_zU_out ;
     136       
     137display x1.ipopt_zL_out, x2.ipopt_zL_out, x3.ipopt_zL_out,
     138        et1.ipopt_zL_out, et2.ipopt_zL_out ;
     139
     140# Constraint multipliers
     141display r1, r2, r3, r4 ;
     142
     143#************************
     144# Print updated solution
     145#************************
     146display x1.sens_sol_state_1, x2.sens_sol_state_1,
     147        x3.sens_sol_state_1, et1.sens_sol_state_1,
     148        et2.sens_sol_state_1 ;
     149
     150display x1.sens_sol_state_1_z_U, x2.sens_sol_state_1_z_U,
     151        x3.sens_sol_state_1_z_U,
     152        et1.sens_sol_state_1_z_U, et2.sens_sol_state_1_z_U ;
     153       
     154display x1.sens_sol_state_1_z_L, x2.sens_sol_state_1_z_L,
     155        x3.sens_sol_state_1_z_L,
     156        et1.sens_sol_state_1_z_L, et2.sens_sol_state_1_z_L ;
     157
     158# and updated constraint multipliers
     159display r1.sens_sol_state_1, r2.sens_sol_state_1,
     160        r3.sens_sol_state_1, r4.sens_sol_state_1 ;
     161}}}
     162
     163
     164
     165