1# tell ampl to use the ipopt executable as a solver 2# make sure ipopt is in the path! 3option solver ipopt; 4 5# declare the variables and their bounds, 6# set notation could be used, but this is straightforward 7var x1 >= 1, <= 5; 8var x2 >= 1, <= 5; 9var x3 >= 1, <= 5; 10var x4 >= 1, <= 5; 11 12# specify the objective function 13minimize obj: 14x1 * x4 * (x1 + x2 + x3) + x3; 15 16# specify the constraints 17s.t. 18inequality: 19x1 * x2 * x3 * x4 >= 25; 20 21equality: 22x1^2 + x2^2 + x3^2 +x4^2 = 40; 23 24# specify the starting point 25let x1 := 1; 26let x2 := 5; 27let x3 := 5; 28let x4 := 1; 29 30# solve the problem 31solve; 32 33# ipopt returns the bound multipliers through 34# the suffixes ipopt_zL_out and ipopt_zU_out 35# the user does not need to specify them 36# print the solution and variable bounds multipliers 37display x1; 38display x2; 39display x3; 40display x4; 41display x1.ipopt_zL_out; 42display x1.ipopt_zU_out; 43display x2.ipopt_zL_out; 44display x2.ipopt_zU_out; 45display x3.ipopt_zL_out; 46display x3.ipopt_zU_out; 47display x4.ipopt_zL_out; 48display x4.ipopt_zU_out; 49 50# define initial conditions for bound multipliers 51# to solve new problem 52 53suffix ipopt_zL_in, IN; 54suffix ipopt_zU_in, IN; 55 56let x1.ipopt_zL_in := x1.ipopt_zL_out; 57let x1.ipopt_zU_in := x1.ipopt_zU_out; 58let x2.ipopt_zL_in := x2.ipopt_zL_out; 59let x2.ipopt_zU_in := x2.ipopt_zU_out; 60let x3.ipopt_zL_in := x3.ipopt_zL_out; 61let x3.ipopt_zU_in := x3.ipopt_zU_out; 62let x4.ipopt_zL_in := x4.ipopt_zL_out; 63let x4.ipopt_zU_in := x4.ipopt_zU_out; 64 65# set options for warm-start 66option ipopt_options "warm_start_init_point yes warm_start_bound_push 1e-6 warm_start_mult_bound_push 1e-6 mu_init 1e-6"; 67 68# solve the problem again 69solve; 70