ReFRACtor
FullPhysics::NLLSProblemState Class Reference

The state for a NLLS problem with implemented residual function and its Jacobian. More...

#include <nlls_problem_state.h>

+ Inheritance diagram for FullPhysics::NLLSProblemState:
+ Collaboration diagram for FullPhysics::NLLSProblemState:

Public Member Functions

 NLLSProblemState ()
 Default constructor. More...
 
 NLLSProblemState (const NLLSProblemState &s)
 Copy constructor. More...
 
virtual ~NLLSProblemState ()
 
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 int expected_parameter_size () const
 Returns the expected size of the parameters. 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
 Returns the current 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
 Prints description of object. More...
 
std::string print_to_string () const
 Print to string. More...
 
virtual void set (const NLLSProblemState &s)
 Makes self a copy of the input state. More...
 
virtual void set (const ProblemState &s)
 Makes self a copy of the input state. More...
 

Protected Attributes

blitz::Array< double, 2 > J
 
blitz::Array< double, 1 > R
 
blitz::Array< double, 1 > X
 

Detailed Description

The state for a NLLS problem with implemented residual function and its Jacobian.

NLLSProblemState is used for the Non-Linear Least Squares problem that its residual function and Jacobian are implemented. With this class one can store the current point in the parameter space (the state), the value of the residual vector function at that point, and the Jacobian matrix function at the same point.

Design related question(s):

  1. Why is NLLSProblemState not derived from CostFuncDiffState?
  2. Why not first implement a problem state class that only adds residual to the state and then derive this class (with residual and Jacobian) from that class (similar to CostFuncState and CostFuncDiffState)?

Answers to the above question(s):

  1. Keep in mind that the purpose of the classes in the class hierarchy rooted at ProblemState is to maintain computationally expensive components of the cost function. If the residual and the Jacobian of a NLLS problem are computed, then the cost function and its gradient can be computed very fast. If f(x) and J(x) are the residual and the Jacobian of the NLLS problem respectively evaluated at x, then the cost function and its gradient respectively are

    \[ \frac{1}{2}\parallel f(x) \parallel^2 \]

    and

    \[ J(x)^T f(x) \]

  2. If the Jacobian of a residual function is not available, then the only methods that can solve the optimization problem use the cost function. In other words, in this case the problem is solved in a form that is presented by CostFunc class. For the problem in CostFunc form, CostFuncState state class is sufficient.

Definition at line 48 of file nlls_problem_state.h.

Constructor & Destructor Documentation

◆ NLLSProblemState() [1/2]

FullPhysics::NLLSProblemState::NLLSProblemState ( )
inline

Default constructor.

Definition at line 58 of file nlls_problem_state.h.

◆ NLLSProblemState() [2/2]

FullPhysics::NLLSProblemState::NLLSProblemState ( const NLLSProblemState s)
inline

Copy constructor.

Parameters
[in]sanother NLLSProblemState

Definition at line 68 of file nlls_problem_state.h.

◆ ~NLLSProblemState()

virtual FullPhysics::NLLSProblemState::~NLLSProblemState ( )
inlinevirtual

Definition at line 72 of file nlls_problem_state.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::NLLSProblemState::clear ( )
inlinevirtual

Deletes data contents.

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

Reimplemented from FullPhysics::ProblemState.

Definition at line 96 of file nlls_problem_state.h.

◆ expected_parameter_size()

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

Returns the expected size of the parameters.

This method must be reimplemented by the problem class the inherits ProblemState. It is only in the context of an optimization problem that one knows what the size of the parameters (number of the dimensions of the parameter space) is.

This method is intentionally implemented here instead of being left as a pure virtual method. The intention is that the user to be able to create an object of this class or its derived classes for the purpose of preserving an older state of a problem if needed.

Returns
Expected size of parameters

Reimplemented in FullPhysics::NLLSMaxAPosteriori, FullPhysics::NLLSMaxLikelihood, FullPhysics::NLLSProblemScaled, FullPhysics::ModelMeasureStandard, FullPhysics::ModelMeasureBard, FullPhysics::ModelMeasureMeyer, FullPhysics::FmNLLSProblem, FullPhysics::BardNLLSProblem, FullPhysics::BrownNLLSProblem, FullPhysics::FreudensteinRothNLLSProblem, FullPhysics::HelicalValleyNLLSProblem, FullPhysics::JennrichSampsonNLLSProblem, FullPhysics::MeyerNLLSProblem, FullPhysics::PowellNLLSProblem, FullPhysics::PowellSingularNLLSProblem, and FullPhysics::Rosenbrock2NLLSProblem.

Definition at line 185 of file problem_state.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 ProblemState::parameters ( const blitz::Array< double, 1 > &  x)
virtualinherited

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

The method calls parameters_different() to determine whether or not the new parameters are different:

  • If different, then it deletes the object state (see clear()), and the input x becomes the current state.
  • If not different, then the input parameters are ignored.
Parameters
[in]xNew set of parameters

Reimplemented in FullPhysics::NLLSProblemScaled, FullPhysics::NLLSMaxAPosteriori, FullPhysics::NLLSMaxLikelihood, and FullPhysics::ModelMeasureStandard.

Definition at line 36 of file problem_state.cc.

◆ parameters() [2/2]

virtual blitz::Array<double, 1> FullPhysics::ProblemState::parameters ( ) const
inlinevirtualinherited

Returns the current parameters.

Returns
Current parameter

Reimplemented in FullPhysics::NLLSProblemScaled, FullPhysics::NLLSMaxAPosteriori, FullPhysics::NLLSMaxLikelihood, and FullPhysics::ModelMeasureStandard.

Definition at line 153 of file problem_state.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()

◆ 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.

◆ set() [1/2]

void NLLSProblemState::set ( const NLLSProblemState s)
virtual

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 NLLSProblemState

Definition at line 7 of file nlls_problem_state.cc.

◆ set() [2/2]

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.

Member Data Documentation

◆ J

blitz::Array<double, 2> FullPhysics::NLLSProblemState::J
protected

Definition at line 111 of file nlls_problem_state.h.

◆ R

blitz::Array<double, 1> FullPhysics::NLLSProblemState::R
protected

Definition at line 110 of file nlls_problem_state.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