Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
BarrierFunction.hpp
Go to the documentation of this file.
1 /*
2  * $Id: BarrierFunction.hpp 135 2013-06-29 15:09:42Z jdl3 $
3  * Copyright (C) 2013 John D Lamb
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or (at
8  * your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef IPO_DETAIL_BARRIERFUNCTION_HPP
21 #define IPO_DETAIL_BARRIERFUNCTION_HPP
22 
23 #include"../Model.hpp"
24 #include"../../ipo_function/DerivativesEstimates.hpp"
25 
26 namespace ipo {
31  namespace detail {
37  public:
41  enum class Sign { positive, negative };
52  double const t = 0.1 );
57  virtual double operator()( gsl::vector const& vector );
63  virtual gsl::vector gradient( gsl::vector const& vector );
69  virtual gsl::matrix hessian( gsl::vector const& vector );
74  virtual gsl::vector gradient(){ return DerivativesEstimates::gradient(); }
79  virtual gsl::matrix hessian(){ return DerivativesEstimates::hessian(); }
84  void set_t( double const t );
89  double get_t() const;
96  virtual void setVector( gsl::vector const& vector );
97  protected:
104  void initialiseResultFromObjective( gsl::vector& subvector, bool const simul = false );
113  void updateResultFromConstraint( Constraint& constraint, gsl::vector& subvector,
114  double const& lowerBound, double const& functionValue,
115  double const& upperBound );
121  void updateResultFromVariable( std::map<Variable,size_t>::value_type& entry,
122  gsl::vector const& vector );
130  gsl::vector initialiseGradientFromObjective( gsl::vector& subvector,
131  bool const simul = false );
143  gsl::vector updateGradientFromConstraint( size_t const constraintIndex,
144  gsl::vector& subvector, double const& lowerBound,
145  double const& functionValue,
146  double const& upperBound,
147  bool const simul = false );
153  void updateGradientFromVariable( std::map<Variable,size_t>::value_type& entry,
154  gsl::vector const& vector );
161  void initialiseHessianFromObjective( gsl::vector& subvector, bool const simul = false );
173  void updateHessianFromConstraint( size_t const constraintIndex,
174  gsl::vector& subvector, double const& lowerBound,
175  double const& functionValue,
176  double const& upperBound, gsl::vector& gradient,
177  bool const simul = false );
183  void updateHessianFromVariable( std::map<Variable,size_t>::value_type& entry,
184  gsl::vector const& vector );
193  Sign const sign;
197  double t;
198  };
199 
200  }
201 }
202 
203 #endif
virtual gsl::matrix hessian()
Get Hessian value from last call to setValue();.
void set_t(double const t)
Set t to a new value.
void updateHessianFromVariable(std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector)
Update hessian from a variable.
Sign const sign
Set this to true or false according as the objective is to be added or subtracted.
double functionValue
The function value.
void updateResultFromVariable(std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector)
Update result from a variable.
void initialiseHessianFromObjective(gsl::vector &subvector, bool const simul=false)
Update gradient from objective.
virtual void setVector(gsl::vector const &vector)
Set value of vector.
virtual double operator()(gsl::vector const &vector)
Evaluate the function.
gsl::vector updateGradientFromConstraint(size_t const constraintIndex, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound, bool const simul=false)
Update gradient from a constraint.
Model & model
The value t used to determine the barrier.
Base class for derivative estimates with Hessian.
double t
The value t used to determine the barrier.
virtual gsl::vector gradient()
Get gradient value from last call to setValue();.
Class for a constraint function.
Definition: Constraint.hpp:40
Model an interior-point optimisation problem.
Definition: Model.hpp:325
double get_t() const
Get t value.
void updateResultFromConstraint(Constraint &constraint, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound)
Update result from a constraint.
This class computes a function at a vector.
Definition: Function.hpp:38
gsl::vector initialiseGradientFromObjective(gsl::vector &subvector, bool const simul=false)
Update gradient from objective.
Sign
Enumerated type used to determine sign of objective in BarrierFunction.
void updateHessianFromConstraint(size_t const constraintIndex, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound, gsl::vector &gradient, bool const simul=false)
Update Hessian from a constraint.
BarrierFunction(Model &model, Sign const sign=Sign::positive, double const t=0.1)
The constructor needs a Model.
Function for the logarithmic barrier.
void initialiseResultFromObjective(gsl::vector &subvector, bool const simul=false)
Update result from objective.
data lowerBound
Definition: Variable.cc:39
data upperBound
Definition: Variable.cc:38
void updateGradientFromVariable(std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector)
Update gradient from a variable.
This namespace holds all the interior-point optimisation classes.
Definition: Array.hpp:28