@c Copyright (C) 1996-2015 John W. Eaton
@c
@c This file is part of Octave.
@c
@c Octave is free software; you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by the
@c Free Software Foundation; either version 3 of the License, or (at
@c your option) any later version.
@c
@c Octave is distributed in the hope that it will be useful, but WITHOUT
@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@c for more details.
@c
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <http://www.gnu.org/licenses/>.

@node Optimization, Quadrature, Nonlinear Equations, Top
@chapter Optimization
@cindex optimization

@menu
* Objective Functions::
* Bounds::
* Linear Constraints::
* Nonlinear Constraints::
* Quadratic Programming::
* Nonlinear Programming::
@end menu

@node Objective Functions, Bounds, Optimization, Optimization
@section Objective Functions
@cindex objective functions

@deftypefn  {} {} Objective (void)
@deftypefnx  {} {} Objective (const @var{objective_fcn})
@deftypefnx  {} {} Objective (const @var{objective_fcn}, const @var{gradient_fcn})
@deftypefnx  {} {} Objective (const Objective &@var{a})
@end deftypefn

@deftypefn {} Objective& {operator =} (const Objective &@var{a})
@end deftypefn

@deftypefn {} objective_fcn objective_function (void) const;
@end deftypefn

@deftypefn {} Objective& set_objective_function (const @var{objective_fcn})
@end deftypefn

@deftypefn {} gradient_fcn gradient_function (void) const;
@end deftypefn

@deftypefn {} Objective& set_gradient_function (const @var{gradient_fcn})
@end deftypefn

@c ------------------------------------------------------------------------

@node Bounds, Linear Constraints, Objective Functions, Optimization
@section Bounds
@cindex bounds

@deftypefn  {} {} Bounds (void)
@deftypefnx  {} {} Bounds (int @var{n})
@deftypefnx  {} {} Bounds (const ColumnVector @var{lb}, const ColumnVector @var{ub})
@deftypefnx  {} {} Bounds (const Bounds &@var{a})
@end deftypefn

@deftypefn {} Bounds& {operator =} (const Bounds &@var{a})
@end deftypefn

@deftypefn {} Bounds& resize (int @var{n})
@end deftypefn

@deftypefn {} double lower_bound (int @var{index}) const;
@deftypefnx {} double upper_bound (int @var{index}) const;
@end deftypefn

@deftypefn {} ColumnVector lower_bounds (void) const;
@deftypefnx {} ColumnVector upper_bounds (void) const;
@end deftypefn

@deftypefn {} int size (void) const;
@end deftypefn

@deftypefn {} Bounds& set_bound (int @var{index}, double @var{low}, double @var{high})
@end deftypefn

@deftypefn {} Bounds& set_bounds (double @var{low}, double @var{high})
@deftypefnx {} Bounds& set_bounds (const ColumnVector @var{lb}, const ColumnVector @var{ub})
@end deftypefn

@deftypefn {} Bounds& set_lower_bound (int @var{index}, double @var{low})
@deftypefnx {} Bounds& set_upper_bound (int @var{index}, double @var{high})
@end deftypefn

@deftypefn {} Bounds& set_lower_bounds (double @var{low})
@deftypefnx {} Bounds& set_upper_bounds (double @var{high})
@end deftypefn

@deftypefn {} Bounds& set_lower_bounds (const ColumnVector @var{lb})
@deftypefnx {} Bounds& set_upper_bounds (const ColumnVector @var{ub})
@end deftypefn

@deftypefn {} {ostream&} {operator <<} (ostream &@var{os}, const Bounds &@var{b})
@end deftypefn

@c ------------------------------------------------------------------------

@node Linear Constraints, Nonlinear Constraints, Bounds, Optimization
@section Linear Constraints
@cindex linear Constraints

@deftypefn  {} {} LinConst (void)
@deftypefnx  {} {} LinConst (int @var{nclin}, int @var{nx})
@deftypefnx  {} {} LinConst (int @var{nclin_eq}, int @var{nclin_ineq}, int @var{nx})
@deftypefnx  {} {} LinConst (const ColumnVector &@var{lb}, const Matrix &@var{A}, const ColumnVector &@var{ub})
@deftypefnx  {} {} LinConst (const Matrix &@var{A_eq}, const ColumnVector &@var{b_eq}, const Matrix &@var{A_ineq}, const ColumnVector &@var{b_ineq})
@deftypefnx  {} {} LinConst (const LinConst &@var{a})
@end deftypefn

@deftypefn {} LinConst& {operator =} (const LinConst &@var{a})
@end deftypefn

@deftypefn {} LinConst& resize (int @var{nclin}, int @var{n})
@end deftypefn

@deftypefn {} Matrix constraint_matrix (void) const;
@end deftypefn

@deftypefn {} LinConst& set_constraint_matrix (const Matrix &@var{A})
@end deftypefn

@deftypefn {} Matrix eq_constraint_matrix (void) const;
@deftypefnx {} Matrix ineq_constraint_matrix (void) const;
@end deftypefn

@deftypefn {} ColumnVector eq_constraint_vector (void) const;
@deftypefnx {} ColumnVector ineq_constraint_vector (void) const;
@end deftypefn

@deftypefn {} {ostream&} {operator <<} (ostream &@var{os}, const LinConst &@var{b})
@end deftypefn

@c ------------------------------------------------------------------------

@node Nonlinear Constraints, Quadratic Programming, Linear Constraints, Optimization
@section Nonlinear Constraints
@cindex nonlinear Constraints

@deftypefn  {} {} NLConst (void)
@deftypefnx  {} {} NLConst (int @var{n})
@deftypefnx  {} {} NLConst (const ColumnVector @var{lb}, const NLFunc @var{f}, const ColumnVector @var{ub})
@deftypefnx  {} {} NLConst (const NLConst &@var{a})
@end deftypefn

@deftypefn {} NLConst& {operator =} (const NLConst &@var{a})
@end deftypefn

@node Quadratic Programming, Nonlinear Programming, Nonlinear Constraints, Optimization
@section Quadratic Programming
@cindex QP
@cindex quadratic programming

@deftypefn  {} {} QP (void)
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const ColumnVector &@var{c})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const Bounds &@var{b})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const LinConst &@var{lc})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const ColumnVector &@var{c}, const Bounds &@var{b})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const ColumnVector &@var{c}, const LinConst &@var{lc})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const Bounds &@var{b}, const LinConst &@var{lc})
@deftypefnx  {} {} QP (const ColumnVector &@var{x}, const Matrix &@var{H}, const ColumnVector &@var{c}, const Bounds &@var{b}, const LinConst &@var{lc})
@end deftypefn

@deftypefn {} {virtual ColumnVector} minimize (void)
@deftypefnx {} {virtual ColumnVector} minimize (double &@var{objf})
@deftypefnx {} {virtual ColumnVector} minimize (double &@var{objf}, int &@var{inform})
@deftypefnx {} {virtual ColumnVector} minimize (double &@var{objf}, int &@var{inform}, ColumnVector &@var{lambda}) = 0;
@end deftypefn

@deftypefn {} {virtual ColumnVector} minimize (const ColumnVector &@var{x})
@deftypefnx {} {virtual ColumnVector} minimize (const ColumnVector &@var{x}, double &@var{objf})
@deftypefnx {} {virtual ColumnVector} minimize (const ColumnVector &@var{x}, double &@var{objf}, int &@var{inform})
@deftypefnx {} {virtual ColumnVector} minimize (const ColumnVector &@var{x}, double &@var{objf}, int &@var{inform}, ColumnVector &@var{lambda})
@end deftypefn

@deftypefn {} ColumnVector minimize (double &@var{objf}, int &@var{inform}, ColumnVector &@var{lambda})
@end deftypefn

@c ------------------------------------------------------------------------

@node Nonlinear Programming,  , Quadratic Programming, Optimization
@section Nonlinear Programming
@cindex NLP
@cindex nonlinear programming

@deftypefn  {} {} NLP (void)
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const Bounds &@var{b})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const Bounds &@var{b}, const LinConst &@var{lc})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const Bounds &@var{b}, const LinConst &@var{lc}, const NLConst &@var{nlc})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const LinConst &@var{lc})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const LinConst &@var{lc}, const NLConst &@var{nlc})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const NLConst &@var{nlc})
@deftypefnx  {} {} NLP (const ColumnVector &@var{x}, const Objective &@var{phi}, const Bounds &@var{b}, const NLConst &@var{nlc})
@end deftypefn

@deftypefn {} NLP& {operator =} (const NLP &@var{a})
@end deftypefn

@deftypefn {} int size (void) const
@end deftypefn

@deftypefn {} ColumnVector minimize (void)
@deftypefnx {} ColumnVector minimize (double &@var{objf})
@deftypefnx {} ColumnVector minimize (double &@var{objf}, int &@var{inform})
@deftypefnx {} ColumnVector minimize (double &@var{objf}, int &@var{inform}, ColumnVector &@var{lambda})
@end deftypefn

@deftypefn {} ColumnVector minimize (const ColumnVector &@var{x})
@deftypefnx {} ColumnVector minimize (const ColumnVector &@var{x}, double &@var{objf})
@deftypefnx {} ColumnVector minimize (const ColumnVector &@var{x}, double &@var{objf}, int &@var{inform})
@deftypefnx {} ColumnVector minimize (const ColumnVector &@var{x}, double &@var{objf}, int &@var{inform}, ColumnVector &@var{lambda})
@end deftypefn
