Changeset 1416


Ignore:
Timestamp:
Mar 5, 2009 6:14:06 PM (11 years ago)
Author:
pcarbo
Message:

Made a few changes to the documentation for the MATLAB interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-peter/Ipopt/contrib/MatlabInterface/ipopt.m

    r1412 r1416  
    1717%
    1818%     Calculates the objective function at the current point. It takes one
    19 %     point, the current iterate x.
     19%     point, the current iterate x. For example, the definition of the
     20%     objective function for the Hock & Schittkowski (H&S) test problem #71
     21%     (with 4 optimization variables) would be
     22%
     23%         function f = objective (x)
     24%           f = x(1)*x(4)*sum(x(1:3)) + x(3);
    2025%         
    2126%     funcs.gradient (required)
    2227%
    23 %     Computes the gradient of the objective at the current point. It
    24 %     takes one input, the current iterate x.
     28%     Computes the gradient of the objective at the current point. It takes
     29%     one input, the current iterate x. For H&S test problem #71, the
     30%     definition of the gradient callback would be
     31%
     32%         function g = gradient (x)
     33%           g = [ x(1)*x(4) + x(4)*sum(x(1:3))
     34%                 x(1)*x(4)
     35%                 x(1)*x(4) + 1
     36%                 x(1)*sum(x(1:3)) ];
    2537%
    2638%     funcs.constraints (optional)
     
    3042%     point. It takes one input, x. The return value is a vector of length
    3143%     equal to the number of constraints (it must be of the same length as
    32 %     options.cl and options.cu).
     44%     options.cl and options.cu). For H&S test problem #71, the
     45%     callback definition would be
     46%
     47%         function c = constraints (x)
     48%           c = [ prod(x); sum(x.^2) ];
    3349%
    3450%     funcs.jacobian (optional)
     
    3955%     sparse matrix, where M is the number of constraints and N is the
    4056%     number of variables. Type HELP SPARSE for more information on
    41 %     constructing sparse matrices in MATLAB.
     57%     constructing sparse matrices in MATLAB. The definition of the
     58%     callback function for H&S test problem #71 would be
     59%
     60%         function J = jacobian (x)
     61%           sparse([ prod(x)./x; 2*x ]);
     62%
     63%     Notice that the return value is a sparse matrix.
    4264%
    4365%     funcs.jacobianstructure (optional)
     
    4668%     variables. It takes no inputs. The return value is a sparse
    4769%     matrix whereby an entry is nonzero if and only if the Jacobian of
    48 %     the constraints is nonzero at ANY point.
     70%     the constraints is nonzero at ANY point. The callback function for
     71%     the H&S test problem #71 simply returns a 2 x 4 matrix of ones in
     72%     the sparse matrix format:
     73%
     74%         function J = jacobianstructure()
     75%           J = sparse(ones(2,4));
    4976%
    5077%     funcs.hessian (optional)
     
    6794%     the output value, then X must be the same as TRIL(X).
    6895%
     96%     Here is an implementation of the Hessian callback routine for the
     97%     H&S test problem #71:
     98%
     99%         function H = hessian (x, sigma, lambda)
     100%           H = sigma*[ 2*x(4)             0      0   0;
     101%                       x(4)               0      0   0;
     102%                       x(4)               0      0   0;
     103%                       2*x(1)+x(2)+x(3)  x(1)  x(1)  0 ];
     104%           H = H + lambda(1)*[    0          0         0         0;
     105%                               x(3)*x(4)     0         0         0;
     106%                               x(2)*x(4) x(1)*x(4)     0         0;
     107%                               x(2)*x(3) x(1)*x(3) x(1)*x(2)     0  ];
     108%           H = sparse(H + lambda(2)*diag([2 2 2 2]));
     109
    69110%     funcs.hessianstructure (optional)
    70111%
     
    72113%     for the Hessian matrix. Again, it is not needed if you are using the
    73114%     limited-memory quasi-Newton approximation to the Hessian. It takes no
    74 %     inputs, and must return a sparse, lower triangular matrix.
     115%     inputs, and must return a sparse, lower triangular matrix. For H&S
     116%     test problem #71, the MATLAB callback routine is fairly
     117%     straightforward:
     118%
     119%         function H = hessianstructure()
     120%           H = sparse(tril(ones(4)));
    75121%
    76122%     funcs.iterfunc (optional)
     
    112158%     IPOPT optimization. The auxiliary data keep the same values as they
    113159%     possessed in the initial call. If you need variables that change over
    114 %     time, you may want to consider global variables (type HELP GLOBAL).
     160%     time, you may want to consider global variables (type HELP
     161%     GLOBAL). See the lasso.m file in the examples subdirectory for an
     162%     illustration of how the auxiliary data is passed to the various
     163%     callback functions.
    115164%
    116165%     options.zl, options.zu, options.lambda
Note: See TracChangeset for help on using the changeset viewer.