Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
NewtonDescent.hpp
Go to the documentation of this file.
1 /*
2  * $Id: NewtonDescent.hpp 105 2013-06-02 15:46:43Z jdl3 $
3  * Copyright (C) 2011, 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_NEWTONDESCENT_HPP
21 #define IPO_DETAIL_NEWTONDESCENT_HPP
22 
23 #include<cmath>
24 #include<limits>
25 #include<ostream>
26 #include<iomanip>
27 #include<ccgsl/blas.hpp>
28 #include<ccgsl/linalg.hpp>
29 #include"LineSearch.hpp"
30 #include"../../ipo_function/DerivativesEstimates.hpp"
31 #include"GSL.hpp"
32 #include"../IPOException.hpp"
33 
34 namespace ipo {
35  namespace detail {
36 
50  class NewtonDescent {
51  public:
56  class Parameters {
57  public:
61  Parameters();
66  void setOutputStream( std::ostream* outputStream );
71  std::ostream* getOutputStream() const;
75  bool getPhaseI() const { return phaseI; }
87  void setPhaseI( bool const phaseI ){ this->phaseI = phaseI; }
92  void setGradTol( double const gradTol ){ this->gradTol = gradTol; }
97  void setStepTol( double const stepTol ){ this->stepTol = stepTol; }
102  void setIterMax( size_t const iterMax ){ this->iterMax = iterMax; }
107  void setf_typ( double const f_typ ){ this->f_typ = f_typ; }
112  void setx_typ( gsl::vector x_typ ){ this->x_typ = x_typ; }
117  double getGradTol() const { return gradTol; }
122  double getStepTol() const { return stepTol; }
127  size_t getIterMax() const { return iterMax; }
132  double getf_typ() const { return f_typ; }
137  gsl::vector getx_typ() const { return x_typ; }
144  void setVectorDigits( size_t const vectorDigits ){
145  this->vectorDigits = vectorDigits; }
151  size_t getVectorDigits() const { return vectorDigits; }
152  private:
159  std::ostream* outputStream;
166  bool phaseI;
176  double gradTol;
187  double stepTol;
198  size_t iterMax;
204  double f_typ;
211  gsl::vector x_typ;
217  size_t vectorDigits;
218  };
219  private:
221  public:
236  gsl::matrix const equalityConstraintsMatrix = gsl::matrix(),
237  gsl::vector const equalityConstraintsBounds = gsl::vector() );
245  double operator()( gsl::vector& x, double objectiveValue );
251  void setFunctionScale( double const functionScale ){
252  this->functionScale = functionScale; }
256  enum struct StoppingCondition {
257  gradTol,
258  stepTol,
259  iterMax,
260  noStopping
261  };
271  Parameters& getParameters();
277  protected:
278  // Forward declaration
279  class Stopping;
280  friend class Stopping;
290  gsl::matrix const equalityConstraintsMatrix;
311  gsl::matrix A;
316  gsl::matrix V;
321  gsl::vector S;
326  gsl::vector work;
331  gsl::vector b;
332  };
333 
343  public:
361  bool operator()( size_t const iteration, double const fValue, gsl::vector const& gradient,
362  gsl::vector const& vector, gsl::vector const& lastVector ) const;
363  private:
365  };
366  }
367 }
368 
369 #endif
void setStepTol(double const stepTol)
Set the value of stepTol.
void setx_typ(gsl::vector x_typ)
Set the value of typical value of argument.
double functionScale
Scaling factor for output of function values.
double stepTol
The Newton descent needs a stopping condition.
double operator()(gsl::vector &x, double objectiveValue)
The function object operator.
double getf_typ() const
Get the value of typical value of function.
void setOutputStream(std::ostream *outputStream)
Set outputStream.
Newton descent method.
size_t getIterMax() const
Get the value of iterMax.
Parameters()
Constructor: sets default values.
NewtonDescent(ipo_function::Function &function, ipo_function::DerivativesEstimates &de, gsl::matrix const equalityConstraintsMatrix=gsl::matrix(), gsl::vector const equalityConstraintsBounds=gsl::vector())
The constructor needs a Function and a DerivativesEstimates (which may be identical).
Stopping(NewtonDescent const &newtonDescent)
Constructor.
gsl::vector getx_typ() const
Get the value of typical value of argument.
gsl::vector work
This vector is used in singular value decompostion and its size is set in constructor if it is needed...
void setVectorDigits(size_t const vectorDigits)
Set the number of significant digits of entries of vector to show in each Newton step.
bool operator()(size_t const iteration, double const fValue, gsl::vector const &gradient, gsl::vector const &vector, gsl::vector const &lastVector) const
Test the stopping conditions.
gsl::matrix const equalityConstraintsMatrix
This must be set in the constructor.
StoppingCondition getLastStoppingCondition() const
Get Last stopping condition.
Base class for derivative estimates with Hessian.
gsl::vector x_typ
Typical argument value: default is no unspecified vector (evaluates to false), which is interpreted a...
size_t getVectorDigits() const
Get the value of vectorDigits.
void setIterMax(size_t const iterMax)
Set the value of iterMax.
Backtracking line search.
Definition: LineSearch.hpp:36
double getStepTol() const
Get the value of stepTol.
LineSearch lineSearch
We need a LineSearch object: backtracking line search.
StoppingCondition
Enumeration for stopping conditions.
gsl::vector b
This vector is used in singular value decompostion and its size is set in constructor if it is needed...
StoppingCondition lastStoppingCondition
Last stopping condition.
ipo_function::DerivativesEstimates & de
The object containing the function and derivatives estimates.
This class computes a function at a vector.
Definition: Function.hpp:38
void setGradTol(double const gradTol)
Set the value of gradTol.
double f_typ
Typical function value: default is 1.
gsl::vector S
This vector is used in singular value decompostion and its size is set in constructor if it is needed...
gsl::matrix V
This matrix is used in singular value decompostion and its size is set in constructor if it is needed...
gsl::matrix A
This matrix is used in singular value decompostion and its size is set in constructor if it is needed...
size_t vectorDigits
If this value is set to zero and outputStream is not null then vector arguments are not shown (more u...
LineSearch::Parameters & getLineSearchParameters()
Get line search parameters by reference.
std::ostream * getOutputStream() const
Get the current value of outputStream.
Relative step size tolerance reached.
Line search parameters.
Definition: LineSearch.hpp:42
void setf_typ(double const f_typ)
Set the value of typical value of function.
void setFunctionScale(double const functionScale)
Set the scaling factor for output of function values.
double getGradTol() const
Get the value of gradTol.
Parameters & getParameters()
Get parameters by reference.
double gradTol
The Newton descent needs a stopping condition.
bool phaseI
This value Is normally set to false.
size_t iterMax
The Newton descent needs a stopping condition.
This class allows us to test suitable stopping conditions.
void setPhaseI(bool const phaseI)
This function is designed to be used to help find an initial (phase I) feasible solution.
This namespace holds all the interior-point optimisation classes.
Definition: Array.hpp:28
std::ostream * outputStream
A stream (default is nullptr) for sending output to.