// Copyright (C) 2006 International Business Machines and others. // All Rights Reserved. // This code is published under the Common Public License. // // $Id: TutorialCpp_nlp.cpp 1097 2006-07-17 08:21:46Z andreasw $ // // Author: Andreas Waechter IBM 2006-07-16 // // This is part of the Ipopt tutorial at DIMACS's COIN-OR workshop. // // Implementation of the nlp class for execise problem (skeleton) // // param n := 4; // // var x {1..n} <= 0, >= -1.5, := -0.5; // // minimize obj: // sum{i in 1..n} (x[i]-1)^2; // ; // // subject to constr {i in 2..n-1}: // (x[i]^2+1.5*x[i]-i/n)*cos(x[i+1]) - x[i-1] = 0; // // The constant term "i/n" in the constraint is supposed to be input data // #include "TutorialCpp_nlp.hpp" // We use sin and cos #include using namespace Ipopt; // constructor TutorialCpp_NLP::TutorialCpp_NLP(Index N, const Number* a) : N_(N) { // Copy the values for the constants appearing in the constraints a_ = new Number[N_-2]; for (Index i=0; i