codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
// Copyright (C) 2005, 2009 International Business Machines and others. // All Rights Reserved. // This code is published under the Eclipse Public License. // // $Id: hs071_main.cpp 1864 2010-12-22 19:21:02Z andreasw $ // // Authors: Carl Laird, Andreas Waechter IBM 2005-08-10 #include "IpIpoptApplication.hpp" #include "oc_p2p.hpp" // for printf #ifdef HAVE_CSTDIO # include <cstdio> #else # ifdef HAVE_STDIO_H # include <stdio.h> # else # error "don't have header file for stdio" # endif #endif using namespace Ipopt; int main(int argv, char* argc[]) { // Create a new instance of your nlp // (use a SmartPtr, not raw) OCP_P2P *mynlp = new OCP_P2P(); // mynlp -> test_Adolc(); // Create a new instance of IpoptApplication // (use a SmartPtr, not raw) // 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-3); app->Options()->SetIntegerValue("max_iter", 150); app->Options()->SetIntegerValue("print_level", 5); // app->Options()->SetNumericValue("obj_scaling_factor", 20); // app->Options()->SetNumericValue("mumps_pivtol", 1e-5); app->Options()->SetStringValue("mu_strategy", "adaptive"); //app->Options()->SetStringValue("start_with_resto", "yes"); // app->Options()->SetStringValue("derivative_test", "second-order"); app->Options()->SetStringValue("derivative_test", "first-order"); //app->Options()->SetStringValue("derivative_test_print_all", "yes"); app->Options()->SetStringValue("hessian_approximation", "limited-memory"); //app->Options()->SetStringValue("output_file", "ipopt.out"); // The following overwrites the default name (ipopt.opt) of the // options file // app->Options()->SetStringValue("option_file_name", "hs071.opt"); // Intialize the IpoptApplication and process the options ApplicationReturnStatus status; status = app->Initialize(); if (status != Solve_Succeeded) { printf("\n\n*** Error during initialization!\n"); return (int) status; } // return 0; // Ask Ipopt to solve the problem status = app->OptimizeTNLP(SmartPtr<TNLP>((TNLP*) mynlp)); if (status == Solve_Succeeded) { printf("\n\n*** The problem solved!\n"); } else { printf("\n\n*** The problem FAILED!\n"); } // As the SmartPtrs go out of scope, the reference count // will be decremented and the objects will automatically // be deleted. return (int) status; }
Private
[
?
]
Run code
Submit