1#
2#     This file is part of CasADi.
3#
4#     CasADi -- A symbolic framework for dynamic optimization.
5#     Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl,
6#                             K.U. Leuven. All rights reserved.
7#     Copyright (C) 2011-2014 Greg Horn
8#
9#     CasADi is free software; you can redistribute it and/or
10#     modify it under the terms of the GNU Lesser General Public
11#     License as published by the Free Software Foundation; either
12#     version 3 of the License, or (at your option) any later version.
13#
14#     CasADi is distributed in the hope that it will be useful,
15#     but WITHOUT ANY WARRANTY; without even the implied warranty of
16#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17#     Lesser General Public License for more details.
18#
19#     You should have received a copy of the GNU Lesser General Public
20#     License along with CasADi; if not, write to the Free Software
21#     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22#
23#
24from casadi import *
25
26"""
27This example demonstrates how NL-files, which can be generated
28by AMPl or Pyomo, can be imported in CasADi and solved using
29e.g. the interface to AMPL
30
31Joel Andersson
322012
33
34"""
35
36# Create an NLP instance
37nl = NlpBuilder()
38
39# Parse an NL-file
40nl.import_nl("../nl_files/hs107.nl",{"verbose":False})
41
42# NLP solver options
43opts = {}
44opts["expand"] = True
45# opts["verbose"] = True
46# opts["ipopt"] = dict(max_iter=10, linear_solver="ma57", hessian_approximation="limited-memory")
47
48# Create an NLP solver
49nlpsol = nlpsol("nlpsol", "ipopt", nl, opts)
50
51# Solve NLP
52res = nlpsol(lbx=nl.x_lb,
53             ubx=nl.x_ub,
54             lbg=nl.g_lb,
55             ubg=nl.g_ub,
56             x0=nl.x_init)
57