Gadget
Public Member Functions | Protected Attributes | List of all members
BoundLikelihood Class Reference

This is the class used to calculate the likelihood scores based on the bounds of the parameters for the current model. More...

#include <boundlikelihood.h>

Inheritance diagram for BoundLikelihood:
Inheritance graph
Collaboration diagram for BoundLikelihood:
Collaboration graph

Public Member Functions

 BoundLikelihood (CommentStream &infile, const AreaClass *const Area, const TimeClass *const TimeInfo, const Keeper *const keeper, double weight, const char *name)
 This is the default BoundLikelihood contructor. More...
 
virtual ~BoundLikelihood ()
 This is the default BoundLikelihood destructor. More...
 
void Reset (const Keeper *const keeper)
 This function will reset the bounds information for the likelihood calculation. More...
 
virtual void addLikelihood (const TimeClass *const TimeInfo)
 This function will calculate the likelihood score for the current model. More...
 
virtual void printSummary (ofstream &outfile)
 This function will print summary information from the BoundLikelihood likelihood calculation. More...
 
virtual void addLikelihoodKeeper (const TimeClass *const TimeInfo, Keeper *const keeper)
 This function will calculate the likelihood score for the current model after adjusting the parameters. More...
 
virtual void Print (ofstream &outfile) const
 This function will print the summary MigrationPenalty likelihood information. More...
 
- Public Member Functions inherited from Likelihood
 Likelihood (LikelihoodType T, double w, const char *givenname)
 This is the default Likelihood constructor. More...
 
virtual ~Likelihood ()
 This is the default Likelihood destructor. More...
 
virtual void Reset (const TimeClass *const TimeInfo)
 This function will reset the likelihood information. More...
 
virtual void printLikelihood (ofstream &outfile, const TimeClass *const TimeInfo)
 This function will print information from each likelihood calculation. More...
 
double getLikelihood () const
 This will return the weighted likelihood score for the likelihood component. More...
 
LikelihoodType getType () const
 This will return the type of likelihood class. More...
 
double getUnweightedLikelihood () const
 This will return the unweighted likelihood score for the likelihood component. More...
 
double getWeight () const
 This will return the weight applied to the likelihood component. More...
 
virtual void setFleetsAndStocks (FleetPtrVector &Fleets, StockPtrVector &Stocks)
 This will select the fleets and stocks required to calculate the likelihood score. More...
 
- Public Member Functions inherited from HasName
 HasName ()
 This is the default HasName constructor. More...
 
virtual ~HasName ()
 This is the default HasName destructor. More...
 
 HasName (const char *givenname)
 This is the HasName constructor for a specified name. More...
 
const char * getName () const
 This will return a null terminated text string containing the name of the object. More...
 

Protected Attributes

IntVector switchnr
 This is the IntVector of the index of the parameters. More...
 
DoubleVector upperbound
 This is the DoubleVector of the upper bounds. More...
 
DoubleVector lowerbound
 This is the DoubleVector of the lower bounds. More...
 
DoubleVector powers
 This is the DoubleVector of the power applied when the bound has been exceeded. More...
 
DoubleVector lowerweights
 This is the DoubleVector of the weights applied when the lower bound has been exceeded. More...
 
DoubleVector upperweights
 This is the DoubleVector of the weights applied when the upper bound has been exceeded. More...
 
DoubleVector likelihoods
 This is the DoubleVector of the penalty applied when the bound has been exceeded. More...
 
ParameterVector switches
 This is the ParameterVector of the names of the input parameters. More...
 
DoubleVector values
 This is the DoubleVector used to temporarily store the values of the parameters. More...
 
double defLW
 This is the default weight applied when the lower bound is exceeded. More...
 
double defUW
 This is the default weight applied when the upper bound is exceeded. More...
 
double defPower
 This is the default power applied when the bound is exceeded. More...
 
- Protected Attributes inherited from Likelihood
double likelihood
 This stores the calculated score for the likelihood component. More...
 
double weight
 This stores the weight to be applied to the likelihood component. More...
 

Detailed Description

This is the class used to calculate the likelihood scores based on the bounds of the parameters for the current model.

This class calculates a penalty that is applied if any parameters go outside the specified bounds during the optimisation process. The Simulated Annealing algorithm restricts the parameters to be within the bounds, so this component will give a zero likelihood score when that algorithm is being used. The Hooke & Jeeves algorithm doesn't have this restriction, so a penalty is applied to any parameter that is beyond the bound, and the parameter is moved back to the bounds. A 'reasonable' model will have a zero likelihood score from this component.

Constructor & Destructor Documentation

◆ BoundLikelihood()

BoundLikelihood::BoundLikelihood ( CommentStream infile,
const AreaClass *const  Area,
const TimeClass *const  TimeInfo,
const Keeper *const  keeper,
double  weight,
const char *  name 
)

This is the default BoundLikelihood contructor.

Parameters
infileis the CommentStream to read the likelihood parameters from
Areais the AreaClass for the current model
TimeInfois the TimeClass for the current model
keeperis the Keeper for the current model
weightis the weight for the likelihood component
nameis the name for the likelihood component

◆ ~BoundLikelihood()

virtual BoundLikelihood::~BoundLikelihood ( )
inlinevirtual

This is the default BoundLikelihood destructor.

Member Function Documentation

◆ addLikelihood()

virtual void BoundLikelihood::addLikelihood ( const TimeClass *const  TimeInfo)
inlinevirtual

This function will calculate the likelihood score for the current model.

Parameters
TimeInfois the TimeClass for the current model
Note
This function is not used for this likelihood component

Implements Likelihood.

◆ addLikelihoodKeeper()

void BoundLikelihood::addLikelihoodKeeper ( const TimeClass *const  TimeInfo,
Keeper *const  keeper 
)
virtual

This function will calculate the likelihood score for the current model after adjusting the parameters.

Parameters
TimeInfois the TimeClass for the current model
keeperis the Keeper for the current model
Note
keeper can adjust the value of the parameters to ensure that they are within the bounds

Reimplemented from Likelihood.

◆ Print()

void BoundLikelihood::Print ( ofstream &  outfile) const
virtual

This function will print the summary MigrationPenalty likelihood information.

Parameters
outfileis the ofstream that all the model information gets sent to
Note
This function is not used for this likelihood component

Implements Likelihood.

◆ printSummary()

void BoundLikelihood::printSummary ( ofstream &  outfile)
virtual

This function will print summary information from the BoundLikelihood likelihood calculation.

Parameters
outfileis the ofstream that all the model likelihood information gets sent to

Reimplemented from Likelihood.

◆ Reset()

void BoundLikelihood::Reset ( const Keeper *const  keeper)
virtual

This function will reset the bounds information for the likelihood calculation.

Parameters
keeperis the Keeper for the current model

Reimplemented from Likelihood.

Member Data Documentation

◆ defLW

double BoundLikelihood::defLW
protected

This is the default weight applied when the lower bound is exceeded.

◆ defPower

double BoundLikelihood::defPower
protected

This is the default power applied when the bound is exceeded.

◆ defUW

double BoundLikelihood::defUW
protected

This is the default weight applied when the upper bound is exceeded.

◆ likelihoods

DoubleVector BoundLikelihood::likelihoods
protected

This is the DoubleVector of the penalty applied when the bound has been exceeded.

◆ lowerbound

DoubleVector BoundLikelihood::lowerbound
protected

This is the DoubleVector of the lower bounds.

◆ lowerweights

DoubleVector BoundLikelihood::lowerweights
protected

This is the DoubleVector of the weights applied when the lower bound has been exceeded.

◆ powers

DoubleVector BoundLikelihood::powers
protected

This is the DoubleVector of the power applied when the bound has been exceeded.

◆ switches

ParameterVector BoundLikelihood::switches
protected

This is the ParameterVector of the names of the input parameters.

◆ switchnr

IntVector BoundLikelihood::switchnr
protected

This is the IntVector of the index of the parameters.

◆ upperbound

DoubleVector BoundLikelihood::upperbound
protected

This is the DoubleVector of the upper bounds.

◆ upperweights

DoubleVector BoundLikelihood::upperweights
protected

This is the DoubleVector of the weights applied when the upper bound has been exceeded.

◆ values

DoubleVector BoundLikelihood::values
protected

This is the DoubleVector used to temporarily store the values of the parameters.


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