File: ex2.m

package info (click to toggle)
casadi 3.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,964 kB
  • sloc: cpp: 114,229; python: 35,462; xml: 1,946; ansic: 859; makefile: 257; sh: 114; f90: 63; perl: 9
file content (19 lines) | stat: -rw-r--r-- 308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
% MATLAB/Octave
import casadi.*

% Formulate the NLP
x=SX.sym('x');
y=SX.sym('y');
z=SX.sym('z');
f=x^2+100*z^2;
g=z+(1-x)^2-y;
P=struct('x',[x;y;z],...
         'f',f,'g',g);

% Create solver instance
F=nlpsol('F','ipopt',P);

% Solve the problem
r=F('x0',[2.5 3.0 0.75],...
    'ubg',0,'lbg',0);
disp(r.x)