Public Member Functions | Static Public Attributes | Private Member Functions | Friends | List of all members
fuse_core::Loss Class Referenceabstract

The Loss function interface definition. More...

#include <loss.h>

Public Member Functions

virtual Loss::UniquePtr clone () const =0
 Perform a deep copy of the Loss and return a unique pointer to the copy. More...
 
virtual void deserialize (fuse_core::BinaryInputArchive &)=0
 Deserialize data from the provided binary archive into this Loss. More...
 
virtual void deserialize (fuse_core::TextInputArchive &)=0
 Deserialize data from the provided text archive into this Loss. More...
 
 FUSE_SMART_PTR_ALIASES_ONLY (Loss)
 
virtual void initialize (const std::string &name)=0
 Perform any required post-construction initialization, such as reading from the parameter server. More...
 
 Loss ()=default
 Default constructor. More...
 
virtual ceres::LossFunction * lossFunction () const =0
 Return a raw pointer to a ceres::LossFunction that implements the loss function. More...
 
virtual void print (std::ostream &stream=std::cout) const =0
 Print a human-readable description of the loss function to the provided stream. More...
 
virtual void serialize (fuse_core::BinaryOutputArchive &) const =0
 Serialize this Loss into the provided binary archive. More...
 
virtual void serialize (fuse_core::TextOutputArchive &) const =0
 Serialize this Loss into the provided text archive. More...
 
virtual std::string type () const =0
 Returns a unique name for this loss function type. More...
 
virtual ~Loss ()=default
 Destructor. More...
 

Static Public Attributes

static constexpr ceres::Ownership Ownership
 The ownership of the ceres::LossFunction* returned by lossFunction() More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &, const unsigned int)
 The Boost Serialize method that serializes all of the data members in to/out of the archive. More...
 

Friends

class boost::serialization::access
 

Detailed Description

The Loss function interface definition.

This class encapsulates the ceres::LossFunction class, adding the ability to serialize it.

The attributes from all derived ceres::LossFunction classes are private, so we cannot serialize them directly. For that reason we need this fuse_core::Loss to provide additional functionality on top of them.

See http://ceres-solver.org/nnls_modeling.html#lossfunction for a detailed description about loss functions. Basically, a loss function defines the penalty associated with a specific amount error. By default, or if a NULL pointer is provided as the loss function, the penalty will be quadratic. This is the loss function associated with standard least-squares optimization. By providing a different loss function, the penalty for the constraint's error can be altered.

This is generally done to reduce the effect of outlier measurements that made it into the optimization problem. It is always better to remove outliers before they make it into the optimization problem, but no method is perfect. Using robust loss functions can significantly improve the results and stability of the solution in the presence of outlier measurements.

Definition at line 169 of file loss.h.

Constructor & Destructor Documentation

◆ Loss()

fuse_core::Loss::Loss ( )
default

Default constructor.

◆ ~Loss()

virtual fuse_core::Loss::~Loss ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clone()

virtual Loss::UniquePtr fuse_core::Loss::clone ( ) const
pure virtual

Perform a deep copy of the Loss and return a unique pointer to the copy.

This can/should be implemented as follows in all derived classes:

return Derived::make_unique(*this);
Returns
A unique pointer to a new instance of the most-derived Loss

◆ deserialize() [1/2]

virtual void fuse_core::Loss::deserialize ( fuse_core::BinaryInputArchive )
pure virtual

Deserialize data from the provided binary archive into this Loss.

This can/should be implemented as follows in all derived classes:

archive >> *this;
Parameters
[in]archive- The archive holding serialized Loss data

◆ deserialize() [2/2]

virtual void fuse_core::Loss::deserialize ( fuse_core::TextInputArchive )
pure virtual

Deserialize data from the provided text archive into this Loss.

This can/should be implemented as follows in all derived classes:

archive >> *this;
Parameters
[in]archive- The archive holding serialized Loss data

◆ FUSE_SMART_PTR_ALIASES_ONLY()

fuse_core::Loss::FUSE_SMART_PTR_ALIASES_ONLY ( Loss  )

◆ initialize()

virtual void fuse_core::Loss::initialize ( const std::string &  name)
pure virtual

Perform any required post-construction initialization, such as reading from the parameter server.

This will be called on each plugin after construction.

Parameters
[in]nameA unique name to initialize this plugin instance, such as from the parameter server.

◆ lossFunction()

virtual ceres::LossFunction* fuse_core::Loss::lossFunction ( ) const
pure virtual

Return a raw pointer to a ceres::LossFunction that implements the loss function.

The Ceres interface requires a raw pointer. Ceres will take ownership of the pointer and promises to properly delete the loss function when it is done. Additionally, Fuse promises that the Loss object will outlive any generated loss functions (i.e. the Ceres objects will be destroyed before the Loss Function objects). This guarantee may allow optimizations for the creation of the loss function objects.

Returns
A base pointer to an instance of a derived ceres::LossFunction.

◆ print()

virtual void fuse_core::Loss::print ( std::ostream &  stream = std::cout) const
pure virtual

Print a human-readable description of the loss function to the provided stream.

Parameters
streamThe stream to write to. Defaults to stdout.

◆ serialize() [1/3]

template<class Archive >
void fuse_core::Loss::serialize ( Archive &  ,
const unsigned int   
)
inlineprivate

The Boost Serialize method that serializes all of the data members in to/out of the archive.

Parameters
[in/out]archive - The archive object that holds the serialized class members
[in]version- The version of the archive being read/written. Generally unused.

Definition at line 294 of file loss.h.

◆ serialize() [2/3]

virtual void fuse_core::Loss::serialize ( fuse_core::BinaryOutputArchive ) const
pure virtual

Serialize this Loss into the provided binary archive.

This can/should be implemented as follows in all derived classes:

archive << *this;
Parameters
[out]archive- The archive to serialize this loss function into

◆ serialize() [3/3]

virtual void fuse_core::Loss::serialize ( fuse_core::TextOutputArchive ) const
pure virtual

Serialize this Loss into the provided text archive.

This can/should be implemented as follows in all derived classes:

archive << *this;
Parameters
[out]archive- The archive to serialize this loss function into

◆ type()

virtual std::string fuse_core::Loss::type ( ) const
pure virtual

Returns a unique name for this loss function type.

The loss function type string must be unique for each class. As such, the fully-qualified class name is an excellent choice for the type string.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 285 of file loss.h.

Member Data Documentation

◆ Ownership

constexpr ceres::Ownership fuse_core::Loss::Ownership
staticconstexpr
Initial value:
=
ceres::Ownership::TAKE_OWNERSHIP

The ownership of the ceres::LossFunction* returned by lossFunction()

Definition at line 174 of file loss.h.


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


fuse_core
Author(s): Stephen Williams
autogenerated on Thu Apr 24 2025 02:18:55