# source:branches/parallel/Ipopt/contrib/MatlabInterface-Old/examples/examplehs051.m

Last change on this file was 1887, checked in by andreasw, 3 years ago

synchronized with trunk rev 1886; fixed bug in Matrix-vector product for parallel matrix

File size: 1.7 KB
Line
1% Test the "ipopt" Matlab interface on the Hock & Schittkowski test problem
2% #51. See: Willi Hock and Klaus Schittkowski. (1981) Test Examples for
3% Nonlinear Programming Codes. Lecture Notes in Economics and Mathematical
4% Systems Vol. 187, Springer-Verlag.
5%
7% This code is published under the Eclipse Public License.
8%
9% Author: Peter Carbonetto
10%         Dept. of Computer Science
11%         University of British Columbia
12%         May 19, 2007
13function [status, x] = examplehs051
14
15x0  = [ +2.5 +0.5 +2.0 -1.0 +0.5 ];
16lb  = [-inf -inf -inf -inf -inf];
17ub  = [+inf +inf +inf +inf +inf];
18lbc = [4 0 0];
19ubc = [4 0 0];
20
22                   @computeConstraints,@computeJacobian,'',[],'',[],...
23                   'jac_c_constant','yes','hessian_approximation',...
25
26% ----------------------------------------------------------------------
27function f = computeObjective (x)
28
29  f = (x(1) - x(2))^2 + ...
30      (x(2) + x(3) - 2)^2 + ...
31      (x(4) - 1)^2 + (x(5) - 1)^2;
32
33% ----------------------------------------------------------------------
35
36  g = 2*[ x(1) - x(2);
37          x(2) + x(3) - 2 - x(1) + x(2);
38          x(2) + x(3) - 2;
39          x(4) - 1;
40          x(5) - 1 ];
41
42% ----------------------------------------------------------------------
43function c = computeConstraints (x)
44
45  c = [ x(1) + 3*x(2);
46        x(3) + x(4) - 2*x(5);
47        x(2) - x(5) ];
48
49% ----------------------------------------------------------------------
50function J = computeJacobian (x, returnStructureOnly)
51
52  J = sparse([ 1  3  0  0  0;
53               0  0  1  1 -2;
54               0  1  0  0 -1 ]);
55
Note: See TracBrowser for help on using the repository browser.