29 : model( model ), sign { sign }, t{ t }
31 size_t const SIZE { model.
indexMap.size() };
32 functionGradient = gsl::vector( SIZE );
33 functionHessian = gsl::matrix( SIZE, SIZE );
56 subvector = constraintIndices_j->get( vector );
59 double const upperBound { constraint.getUpperBound() };
60 double const lowerBound { constraint.getLowerBound() };
62 double const f { (*constraint.getFunction())( subvector ) };
86 subvector = constraintIndices_j->get( vector );
89 double const upperBound { constraint.getUpperBound() };
90 double const lowerBound { constraint.getLowerBound() };
92 double const f { (*constraint.getFunction())( subvector ) };
116 subvector = constraintIndices_j->get( vector );
119 double const upperBound { constraint.getUpperBound() };
120 double const lowerBound { constraint.getLowerBound() };
122 double const f { (*constraint.getFunction())( subvector ) };
124 gsl::vector
gradient { constraint.getFunction()->gradient( subvector ) };
142 if( simul and
nullptr != de ){
143 de->setVector( subvector );
159 double const& functionValue,
163 this->functionValue -= std::log( upperBound - functionValue );
165 this->functionValue -= std::log( functionValue - lowerBound );
170 gsl::vector
const& vector ){
171 Variable const& variable { entry.first };
173 double const upperBound { variable.getUpperBound() };
174 double const lowerBound { variable.getLowerBound() };
176 double const f = vector[entry.second];
188 gsl::vector
gradient { simul and
nullptr != de ? de->gradient()
206 gsl::vector& subvector,
208 double const& functionValue,
213 gsl::vector
gradient { simul and
nullptr != de ? de->gradient()
214 : constraint.getFunction()->gradient( subvector ) };
217 double const scale_inv { upperBound - functionValue };
218 double const scale { 1.0 / scale_inv };
222 double const scale_inv { lowerBound - functionValue };
223 double const scale { 1.0 / scale_inv };
231 gsl::vector
const& vector ){
232 Variable const& variable { entry.first };
234 double const upperBound { variable.getUpperBound() };
235 double const lowerBound { variable.getLowerBound() };
237 double const f { vector[entry.second] };
241 double const scale { 1.0 / scale_inv };
246 double const scale { 1.0 / scale_inv };
261 gsl::matrix
hessian { simul and
nullptr != de ? de->hessian()
273 gsl::vector& subvector,
275 double const& functionValue,
277 gsl::vector& gradient,
bool const simul ){
281 gsl::matrix
hessian { simul and
nullptr != de ? de->hessian()
282 : constraint.getFunction()->hessian( subvector ) };
285 double const scale_inv { upperBound - functionValue };
286 double const scale { 1.0 / scale_inv };
287 double const scale2 { scale * scale };
292 double const scale_inv { functionValue - lowerBound };
293 double const scale { 1.0 / scale_inv };
294 double const scale2 { scale * scale };
302 gsl::vector
const& vector ){
303 Variable const& variable { entry.first };
305 double const upperBound { variable.getUpperBound() };
306 double const lowerBound { variable.getLowerBound() };
308 double const f { vector[entry.second] };
312 double const scale { 1.0 / scale_inv };
313 double const scale2 { scale * scale };
314 double const d {
functionHessian.get( entry.second, entry.second ) + scale2 };
319 double const scale { 1.0 / scale_inv };
320 double const scale2 { scale * scale };
321 double const d {
functionHessian.get( entry.second, entry.second ) + scale2 };
342 double const upperBound { constraint.getUpperBound() };
343 double const lowerBound { constraint.getLowerBound() };
348 if(
nullptr != de ) de->setVector( subvector );
349 double const f {
nullptr == de ? (*constraint.getFunction())( subvector ) : de->value() };
std::map< Variable, size_t > indexMap
Used internally to match the variables in each variable to indices in a vector.
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.
gsl::vector functionGradient
The gradient value.
double constexpr infinity
Infinity: use for unbounded variables.
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.
gsl::matrix functionHessian
The Hessian value.
double t
The value t used to determine the barrier.
Objective objective
The objective function.
virtual gsl::vector gradient()
Get gradient value from last call to setValue();.
std::vector< Constraint > constraints
The set of constraints.
Class for a constraint function.
virtual gsl::vector gradient(gsl::vector const &vector)
Compute or estimate a gradient value.
Model an interior-point optimisation problem.
double get_t() const
Get t value.
Namespace for classes that handle details of interior-point optimisation that are not ordinarily acce...
void updateResultFromConstraint(Constraint &constraint, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound)
Update result from a constraint.
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.
This class represents a variable.
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.
virtual ::ipo_function::Function * getFunction()
Get function.
void initialiseResultFromObjective(gsl::vector &subvector, bool const simul=false)
Update result from objective.
DerivativesEstimates(size_t const size=0)
Constructor.
double constexpr minusInfinity
Negative infinity: use for unbounded variables.
virtual gsl::matrix hessian(gsl::vector const &vector)
Compute or estimate a Hessian value.
void updateGradientFromVariable(std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector)
Update gradient from a variable.
std::vector< std::shared_ptr< Subvector > > constraintIndices
Used internally to match the variables in each constraint to indices in a vector: (*constraintIndices...
std::shared_ptr< Subvector > objectiveIndices
Used internally to match the variables in the objective to indices in a vector: objectiveIndices[i] i...