[Ipopt] output from Ipopt

Dr Crispin H. W. Barnes chwb101 at cam.ac.uk
Fri May 29 16:33:17 EDT 2009


Hi,

I'm wondering if there is a function I can use to get the final
solution back to the calling program i.e. something like

double [] results = app->Optimize_TNLP_AND_RETURN_RESULT(mynlp);

in the example we have the function finalize_solution but I don't want
to write to stdio

void HS071_NLP::finalize_solution(SolverReturn status,
                                 Index n, const Number* x, const
Number* z_L, const Number* z_U,
                                 Index m, const Number* g, const
Number* lambda,
                                 Number obj_value,
                                 const IpoptData* ip_data,
                                 IpoptCalculatedQuantities* ip_cq)
{
 // here is where we would store the solution to variables, or write
to a file, etc
 // so we could use the solution.

 // For this example, we write the solution to the console
 printf("\n\nSolution of the primal variables, x\n");
 for (Index i=0; i<n; i++) {
   printf("x[%d] = %e\n", i, x[i]);
 }

 printf("\n\nSolution of the bound multipliers, z_L and z_U\n");
 for (Index i=0; i<n; i++) {
   printf("z_L[%d] = %e\n", i, z_L[i]);
 }
 for (Index i=0; i<n; i++) {
   printf("z_U[%d] = %e\n", i, z_U[i]);
 }

 printf("\n\nObjective value\n");
 printf("f(x*) = %e\n", obj_value);

 printf("\nFinal value of the constraints:\n");
 for (Index i=0; i<m ;i++) {
   printf("g(%d) = %e\n", i, g[i]);
 }

thanks for you help.

-- 
Dr Crispin H. W. Barnes
Thin-Film Magnetism
Cavendish Laboratory
University of Cambridge
J.J. Thomson Ave
Cambridge CB3 OHE

Tel:  01223 337487



More information about the Ipopt mailing list