ReFRACtor
FullPhysics::NLLSProblemScaled Class Reference

#include <nlls_problem_scaled.h>

+ Inheritance diagram for FullPhysics::NLLSProblemScaled:
+ Collaboration diagram for FullPhysics::NLLSProblemScaled:

Public Types

enum  message_t { NONE, SOLVED, ERROR }
 Enum type for the message generated by the problem. More...
 

Public Member Functions

 NLLSProblemScaled (const blitz::Array< double, 1 > &s, const boost::shared_ptr< NLLSProblem > &p)
 Default Constructor. More...
 
virtual ~NLLSProblemScaled ()
 
virtual void assert_parameter_correct (const blitz::Array< double, 1 > &x) const
 Checks that the new input parameters are correct. More...
 
virtual void assert_parameter_set_correctly () const
 Checks that the parameters are set correctly. More...
 
virtual void clear ()
 Deletes data contents. More...
 
virtual double cost ()
 Read comments on CostFunc::cost() More...
 
virtual void cost_gradient (double &c, blitz::Array< double, 1 > &g)
 The cost function and its gradient together. More...
 
virtual void cost_gradient_x (const blitz::Array< double, 1 > &x, double &c, blitz::Array< double, 1 > &g)
 The cost function and its gradient with parameters. More...
 
virtual double cost_x (const blitz::Array< double, 1 > &x)
 The cost function with parameters. More...
 
virtual int expected_parameter_size () const
 Return the size of the parameter X. More...
 
virtual blitz::Array< double, 1 > gradient ()
 Read comments on CostFuncDiff::gradient() More...
 
virtual int gradient_size () const
 Returns the size of the gradient vector. More...
 
virtual blitz::Array< double, 1 > gradient_x (const blitz::Array< double, 1 > &x)
 The gradient function with parameters. More...
 
virtual blitz::Array< double, 2 > jacobian ()
 Return the Jacobian of the residual of the scaled NLLS problem at the current set point. More...
 
virtual blitz::Array< double, 2 > jacobian_x (const blitz::Array< double, 1 > &x)
 The Jacobian function with parameters. More...
 
virtual message_t message () const
 Returns a value of CostFunc::message_t type. More...
 
virtual const char *const message_str () const
 Returns the string version of the problem message. More...
 
boost::shared_ptr< NLLSProblemnlls_problem ()
 
virtual int num_cost_evaluations () const
 Returns the number of the times cost has been evaluated. More...
 
virtual int num_der1_evaluations () const
 Returns the number of the times gradient has been evaluated. More...
 
virtual int num_jacobian_evaluations () const
 Returns the number of the times Jacobian has been evaluated. More...
 
virtual int num_residual_evaluations () const
 Returns the number of the times residual has been evaluated. More...
 
virtual int parameter_size () const
 Returns the size of the parameters. More...
 
virtual void parameters (const blitz::Array< double, 1 > &x)
 Sets the problem at a new point in the parameter space. More...
 
virtual blitz::Array< double, 1 > parameters () const
 Just returns the current values of parameters. More...
 
virtual bool parameters_different (const blitz::Array< double, 1 > &x) const
 Checks whether or not new input parameters are different from the current ones. More...
 
virtual void print (std::ostream &Os) const
 Print description of object. More...
 
std::string print_to_string () const
 Print to string. More...
 
virtual blitz::Array< double, 1 > residual ()
 Return the residual of the scaled NLLS problem at the current set point. More...
 
virtual void residual_jacobian (blitz::Array< double, 1 > &r, blitz::Array< double, 2 > &j)
 The residual function and its Jacobian together. More...
 
virtual void residual_jacobian_x (const blitz::Array< double, 1 > &x, blitz::Array< double, 1 > &r, blitz::Array< double, 2 > &j)
 The residual and its Jacobian with parameters. More...
 
virtual int residual_size () const
 The size of the residual returned by residual() More...
 
virtual blitz::Array< double, 1 > residual_x (const blitz::Array< double, 1 > &x)
 The residual function with parameters. More...
 
virtual blitz::Array< double, 1 > scale_parameters (const blitz::Array< double, 1 > &x) const
 If x is the input to the NLLS problem that this class is trying to scale, then this method scales the input to be used by this class, i.e. More...
 
virtual void set (const ProblemState &s)
 Makes self a copy of the input state. More...
 
virtual blitz::Array< double, 1 > unscale_parameters (const blitz::Array< double, 1 > &x) const
 The input is correctly scaled to be used as input to this scaled NLLS problem. More...
 
virtual void zero_num_evaluations ()
 Sets cost and gradient evaluation counters to zero. More...
 

Protected Member Functions

virtual void increment_num_cost_evaluations ()
 Increments (by 1) cost evaluation counter. More...
 
virtual void increment_num_der1_evaluations ()
 Increments (by 1) gradient evaluation counter. More...
 
virtual void set_num_cost_evaluations (int count)
 Sets the cost evaluation counter to a desired value. More...
 
virtual void set_num_der1_evaluations (int count)
 Sets the gradient evaluation counter to a desired value. More...
 

Protected Attributes

message_t mssg
 
boost::shared_ptr< NLLSProblemP
 
blitz::Array< double, 1 > S
 
blitz::Array< double, 1 > X
 

Detailed Description

Definition at line 12 of file nlls_problem_scaled.h.

Member Enumeration Documentation

◆ message_t

Enum type for the message generated by the problem.

In general it is very difficult (probably not possible) to develop a general purpose stopping criterion for a general purpose optimization or curve fitting iterative algorithm. The stopping criterion could be very problem dependent. This enumerated type is used to send a message to the solver of a problem, and the iterative solver can optionally take the message into account in deciding how to proceed.

Enumerator
NONE 

There are no messages.

SOLVED 

The problem is solved.

ERROR 

There is an error in the problem.

Definition at line 38 of file cost_func.h.

Constructor & Destructor Documentation

◆ NLLSProblemScaled()

NLLSProblemScaled::NLLSProblemScaled ( const blitz::Array< double, 1 > &  s,
const boost::shared_ptr< NLLSProblem > &  p 
)

Default Constructor.

Definition at line 31 of file nlls_problem_scaled.cc.

◆ ~NLLSProblemScaled()

virtual FullPhysics::NLLSProblemScaled::~NLLSProblemScaled ( )
inlinevirtual

Definition at line 24 of file nlls_problem_scaled.h.

Member Function Documentation

◆ assert_parameter_correct()

void ProblemState::assert_parameter_correct ( const blitz::Array< double, 1 > &  x) const
virtualinherited

Checks that the new input parameters are correct.

This method checks to see whether or not the new input parameters are correct. If the parameters are not correct then it throws an exception.

Definition at line 44 of file problem_state.cc.

◆ assert_parameter_set_correctly()

virtual void FullPhysics::ProblemState::assert_parameter_set_correctly ( ) const
inlinevirtualinherited

Checks that the parameters are set correctly.

This method checks to see whether or not the parameters are set correctly. If the parameters are not set correctly then it throws an exception.

Definition at line 197 of file problem_state.h.

◆ clear()

virtual void FullPhysics::ProblemState::clear ( )
inlinevirtualinherited

Deletes data contents.

This method deletes state. It must be reimplemented by other classes derived from this class to delete other saved components associated with the state as well.

Reimplemented in FullPhysics::NLLSProblemState, FullPhysics::ModelState, FullPhysics::CostFuncDiffState, and FullPhysics::CostFuncState.

Definition at line 100 of file problem_state.h.

◆ cost()

double NLLSProblem::cost ( )
virtualinherited

Read comments on CostFunc::cost()

Implements FullPhysics::CostFunc.

Definition at line 24 of file nlls_problem.cc.

◆ cost_gradient()

void CostFuncDiff::cost_gradient ( double &  c,
blitz::Array< double, 1 > &  g 
)
virtualinherited

The cost function and its gradient together.

This method passes to the caller the evaluated cost function and its gradient at the current set point.

The parameters (the point in the parameter space) must have already been set before calling this method. The parameters are already set if one of the following methods is already called successfully:

Parameters
[out]cThe cost function value
[out]gThe gradient vector with size gradient_size()

Definition at line 17 of file cost_func_diff.cc.

◆ cost_gradient_x()

virtual void FullPhysics::CostFuncDiff::cost_gradient_x ( const blitz::Array< double, 1 > &  x,
double &  c,
blitz::Array< double, 1 > &  g 
)
inlinevirtualinherited

The cost function and its gradient with parameters.

This method passes to the caller the evaluated cost function and its gradient after setting the problem at the input new point.

Parameters
[in]xNew set of parameters
[out]cThe cost function value
[out]gThe gradient vector with size gradient_size()

Definition at line 128 of file cost_func_diff.h.

◆ cost_x()

virtual double FullPhysics::CostFunc::cost_x ( const blitz::Array< double, 1 > &  x)
inlinevirtualinherited

The cost function with parameters.

This method also evaluates the cost function; however, it sets the problem at the input new point and then evaluates the cost function.

Parameters
[in]xNew set of parameters
Returns
Cost function value

Definition at line 89 of file cost_func.h.

◆ expected_parameter_size()

virtual int FullPhysics::NLLSProblemScaled::expected_parameter_size ( ) const
inlinevirtual

Return the size of the parameter X.

Reimplemented from FullPhysics::ProblemState.

Definition at line 53 of file nlls_problem_scaled.h.

◆ gradient()

blitz::Array< double, 1 > NLLSProblem::gradient ( )
virtualinherited

Read comments on CostFuncDiff::gradient()

Implements FullPhysics::CostFuncDiff.

Definition at line 29 of file nlls_problem.cc.

◆ gradient_size()

virtual int FullPhysics::CostFuncDiff::gradient_size ( ) const
inlinevirtualinherited

Returns the size of the gradient vector.

Returns
The size of the gradient vecotor

Definition at line 157 of file cost_func_diff.h.

◆ gradient_x()

virtual blitz::Array<double, 1> FullPhysics::CostFuncDiff::gradient_x ( const blitz::Array< double, 1 > &  x)
inlinevirtualinherited

The gradient function with parameters.

This method also evaluates the gradient of the cost function; however, it sets the problem at the input new point and then evaluates the gradient.

The size of the gradient vector can be obtained in advance by calling gradient_size().

Parameters
[in]xNew set of parameters
Returns
The gradient of the cost function

Definition at line 82 of file cost_func_diff.h.

◆ increment_num_cost_evaluations()

virtual void FullPhysics::CostFunc::increment_num_cost_evaluations ( )
inlineprotectedvirtualinherited

Increments (by 1) cost evaluation counter.

The developer of a derived class, where the true cost function evaluation is implemented, must also call this method when the cost function is evaluated.

It is possible to call this method in cost_x() method; however, at this level we do not know when the cost function gets truly evaluated.

The developer of a derived class can save the expensive components of a cost function evaluation and reuse them when cost is inquired and the parameters have not changed. Therefore, she has the options of calling increment_num_cost_evaluations()

  1. any time cost is inquired or
  2. only when cost is truly evaluated.

If X1 and X2 are two different sets of parameters, then after the sequence of method calls

  • cost_x(X1)
  • cost_x(X1)
  • cost_x(X2)
  • cost_x(X2)

with the first design option mentioned above num_cost_evaluations() will return 4, but with the second option mentioned above num_cost_evaluations() will return 2.

Therefore, in my opinion it was best not to decide when to call this method at this level in CostFunc class.

Definition at line 198 of file cost_func.h.

◆ increment_num_der1_evaluations()

virtual void FullPhysics::CostFuncDiff::increment_num_der1_evaluations ( )
inlineprotectedvirtualinherited

Increments (by 1) gradient evaluation counter.

The developer of a derived class, where the true gradient evaluation is implemented, must also call this method when the gradient (first order derivatives) is evaluated.

It is possible to call this method in gradient_x() method; however, at this level we do not know when the gradient gets truly evaluated.

The developer of a derived class can save the expensive components of the gradient evaluation and reuse them when gradient is inquired and the parameters have not changed. Therefore, she has the options of calling increment_num_der1_evaluations()

  1. any time gradient is inquired or
  2. only when gradient is truly evaluated.

If X1 and X2 are two different sets of parameters, then after the sequence of method calls

  • gradient_x(X1)
  • gradient_x(X1)
  • gradient_x(X2)
  • gradient_x(X2)

with the first design option mentioned above num_der1_evaluations() will return 4, but with the second option mentioned above num_der1_evaluations() will return 2.

Therefore, in my opinion it was best not to decide when to call this method at this level in CostFuncDiff class.

Definition at line 205 of file cost_func_diff.h.

◆ jacobian()

Array< double, 2 > NLLSProblemScaled::jacobian ( )
virtual

Return the Jacobian of the residual of the scaled NLLS problem at the current set point.

Returns
The Jacobian of the residual function.

Implements FullPhysics::NLLSProblem.

Definition at line 65 of file nlls_problem_scaled.cc.

◆ jacobian_x()

virtual blitz::Array<double, 2> FullPhysics::NLLSProblem::jacobian_x ( const blitz::Array< double, 1 > &  x)
inlinevirtualinherited

The Jacobian function with parameters.

This method also evaluates the Jacobian of the residual of the NLLS problem; however, it sets the problem at the input new point and then evaluates the Jacobian.

The sizes of the Jacobian matrix can be obtained in advance as mentioned in the comments on jacobian() method.

Parameters
[in]xNew set of parameters
Returns
The Jacobian of the residual of the NLLS problem

Definition at line 186 of file nlls_problem.h.

◆ message()

virtual message_t FullPhysics::CostFunc::message ( ) const
inlinevirtualinherited

Returns a value of CostFunc::message_t type.

This method returns a problem generated message. The message is initialized as CostFunc::NONE. The implementation of a problem can optionally set it to other values as needed, and the solver of the problem can optionally take different course of actions for different messages.

It is assumed that the solver will not take any different course of action if the returned value is CostFunc::NONE. For other possible values check the comments on CostFunc::message_t.

Returns
problem message

Definition at line 127 of file cost_func.h.

◆ message_str()

const char *const CostFunc::message_str ( ) const
virtualinherited

Returns the string version of the problem message.

If the method status() returns

then message_str() will return

  • "NONE"
  • "SOLVED"
  • "ERROR"

respectively.

Returns
problem message in string form

Definition at line 14 of file cost_func.cc.

◆ nlls_problem()

boost::shared_ptr<NLLSProblem> FullPhysics::NLLSProblemScaled::nlls_problem ( )
inline

Definition at line 104 of file nlls_problem_scaled.h.

◆ num_cost_evaluations()

virtual int FullPhysics::CostFunc::num_cost_evaluations ( ) const
inlinevirtualinherited

Returns the number of the times cost has been evaluated.

Returns
The number of the times cost has been evaluated.

Definition at line 99 of file cost_func.h.

◆ num_der1_evaluations()

virtual int FullPhysics::CostFuncDiff::num_der1_evaluations ( ) const
inlinevirtualinherited

Returns the number of the times gradient has been evaluated.

Returns
The number of the times gradient has been evaluated.

Definition at line 139 of file cost_func_diff.h.

◆ num_jacobian_evaluations()

virtual int FullPhysics::NLLSProblem::num_jacobian_evaluations ( ) const
inlinevirtualinherited

Returns the number of the times Jacobian has been evaluated.

Returns
The number of the times Jacobian has been evaluated

Definition at line 256 of file nlls_problem.h.

◆ num_residual_evaluations()

virtual int FullPhysics::NLLSProblem::num_residual_evaluations ( ) const
inlinevirtualinherited

Returns the number of the times residual has been evaluated.

Returns
The number of the times residual has been evaluated

Definition at line 246 of file nlls_problem.h.

◆ parameter_size()

virtual int FullPhysics::ProblemState::parameter_size ( ) const
inlinevirtualinherited

Returns the size of the parameters.

Returns
Size of parameters

Definition at line 163 of file problem_state.h.

◆ parameters() [1/2]

void NLLSProblemScaled::parameters ( const blitz::Array< double, 1 > &  x)
virtual

Sets the problem at a new point in the parameter space.

Parameters
xInput value

Reimplemented from FullPhysics::ProblemState.

Definition at line 105 of file nlls_problem_scaled.cc.

◆ parameters() [2/2]

virtual blitz::Array<double, 1> FullPhysics::NLLSProblemScaled::parameters ( ) const
inlinevirtual

Just returns the current values of parameters.

This method is redefined here (see the root base class) because of a compiler bug; otherwise, there should be no need for its redefinition.

Returns
Current parameter values

Reimplemented from FullPhysics::ProblemState.

Definition at line 100 of file nlls_problem_scaled.h.

◆ parameters_different()

bool ProblemState::parameters_different ( const blitz::Array< double, 1 > &  x) const
virtualinherited

Checks whether or not new input parameters are different from the current ones.

The methods checks to see whether or not the new input parameters (point in the parameter space) are different from the parameters maintained by the object for which the method is called.

If the size of the input parameters is not equal to the expected size of the parameters (check comments on expected_parameter_size), then the method will throw an exception.

If the object for which the method is called has currently no parameters set, then the method returns true. Otherwise, the method uses some algorithm to figure out when the difference is "big enough" to be considered different. If the method determines that the new input parameters are different from the current parameters, then it returns true, otherwise, it returns false.

Parameters
[in]xNew set of parameters

Definition at line 9 of file problem_state.cc.

◆ print()

virtual void FullPhysics::NLLSProblemScaled::print ( std::ostream &  Os) const
inlinevirtual

Print description of object.

Reimplemented from FullPhysics::NLLSProblem.

Definition at line 112 of file nlls_problem_scaled.h.

◆ print_to_string()

std::string FullPhysics::Printable< ProblemState >::print_to_string ( ) const
inlineinherited

Print to string.

This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.

Definition at line 31 of file printable.h.

◆ residual()

Array< double, 1 > NLLSProblemScaled::residual ( )
virtual

Return the residual of the scaled NLLS problem at the current set point.

Returns
Residual

Implements FullPhysics::NLLSProblem.

Definition at line 45 of file nlls_problem_scaled.cc.

◆ residual_jacobian()

void NLLSProblem::residual_jacobian ( blitz::Array< double, 1 > &  r,
blitz::Array< double, 2 > &  j 
)
virtualinherited

The residual function and its Jacobian together.

This method passes to the caller the evaluated residual function and its Jacobian at the current set point.

The parameters (the point in the parameter space) must have already been set before calling this method. The parameters are already set if one of the following methods is already called successfully:

Parameters
[out]rThe residual vector
[out]jThe Jacobian matrix

Definition at line 18 of file nlls_problem.cc.

◆ residual_jacobian_x()

virtual void FullPhysics::NLLSProblem::residual_jacobian_x ( const blitz::Array< double, 1 > &  x,
blitz::Array< double, 1 > &  r,
blitz::Array< double, 2 > &  j 
)
inlinevirtualinherited

The residual and its Jacobian with parameters.

This method passes to the caller the evaluated residual function and its Jacobian after setting the problem at the input new point.

Parameters
[in]xNew set of parameters
[out]rThe residual vector
[out]jThe Jacobian matrix

Definition at line 235 of file nlls_problem.h.

◆ residual_size()

virtual int FullPhysics::NLLSProblemScaled::residual_size ( ) const
inlinevirtual

The size of the residual returned by residual()

This method must be implemented by the classes derived from this class.

Returns
The size of the residual that will be returned by residual()

Implements FullPhysics::NLLSProblem.

Definition at line 45 of file nlls_problem_scaled.h.

◆ residual_x()

virtual blitz::Array<double, 1> FullPhysics::NLLSProblem::residual_x ( const blitz::Array< double, 1 > &  x)
inlinevirtualinherited

The residual function with parameters.

This method also evaluates the residual of the NLLS problem; however, it sets the problem at the input new point and then evaluates the residual.

The size of the residual vector can be obtained in advance by calling residual_size().

Parameters
[in]xNew set of parameters
Returns
The residual of the cost function

Definition at line 132 of file nlls_problem.h.

◆ scale_parameters()

Array< double, 1 > NLLSProblemScaled::scale_parameters ( const blitz::Array< double, 1 > &  x) const
virtual

If x is the input to the NLLS problem that this class is trying to scale, then this method scales the input to be used by this class, i.e.

this->parameters(x). The reason for scaling x outside of this->parameters(x) is that we can also scale an already scaled NLLS problem.

In summary, the input x is a correct input directly to the NLLS problem being scaled. The returned value is correctly scaled to be used as input to this scaled NLLS problem.

Definition at line 87 of file nlls_problem_scaled.cc.

◆ set()

virtual void FullPhysics::ProblemState::set ( const ProblemState s)
inlinevirtualinherited

Makes self a copy of the input state.

This method makes the object, for which it is called, a copy of the input state.

Parameters
[in]sanother ProblemState

Definition at line 88 of file problem_state.h.

◆ set_num_cost_evaluations()

virtual void FullPhysics::CostFunc::set_num_cost_evaluations ( int  count)
inlineprotectedvirtualinherited

Sets the cost evaluation counter to a desired value.

This method sets the cost evaluation counter to a desired value. It is just provided if the developers of the derived classes have any use for it

Parameters
[in]countDesired value for cost evaluation counter setting

Definition at line 213 of file cost_func.h.

◆ set_num_der1_evaluations()

virtual void FullPhysics::CostFuncDiff::set_num_der1_evaluations ( int  count)
inlineprotectedvirtualinherited

Sets the gradient evaluation counter to a desired value.

This method sets the gradient (first order derivatives) evaluation counter to a desired value. It is just provided if the developers of the derived classes have any use for it

Parameters
[in]countDesired value for gradient evaluation counter setting

Definition at line 220 of file cost_func_diff.h.

◆ unscale_parameters()

Array< double, 1 > NLLSProblemScaled::unscale_parameters ( const blitz::Array< double, 1 > &  x) const
virtual

The input is correctly scaled to be used as input to this scaled NLLS problem.

The returned value is a correct direct input to the NLLS problem being scaled.

Definition at line 96 of file nlls_problem_scaled.cc.

◆ zero_num_evaluations()

virtual void FullPhysics::CostFuncDiff::zero_num_evaluations ( )
inlinevirtualinherited

Sets cost and gradient evaluation counters to zero.

Reimplemented from FullPhysics::CostFunc.

Definition at line 147 of file cost_func_diff.h.

Member Data Documentation

◆ mssg

message_t FullPhysics::CostFunc::mssg
protectedinherited

Definition at line 163 of file cost_func.h.

◆ P

boost::shared_ptr<NLLSProblem> FullPhysics::NLLSProblemScaled::P
protected

Definition at line 118 of file nlls_problem_scaled.h.

◆ S

blitz::Array<double, 1> FullPhysics::NLLSProblemScaled::S
protected

Definition at line 117 of file nlls_problem_scaled.h.

◆ X

blitz::Array<double, 1> FullPhysics::ProblemState::X
protectedinherited

Definition at line 222 of file problem_state.h.


The documentation for this class was generated from the following files:

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:13