Class Loss

Class Documentation

class Loss

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.

Public Functions

Loss() = default

Default constructor.

virtual ~Loss() = default

Destructor.

virtual void initialize(fuse_core::node_interfaces::NodeInterfaces<fuse_core::node_interfaces::Base, fuse_core::node_interfaces::Logging, fuse_core::node_interfaces::Parameters> interfaces, const std::string &name) = 0

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

This will be called on each plugin after construction.

Parameters:

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

virtual std::string type() const = 0

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.

virtual void print(std::ostream &stream = std::cout) const = 0

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

Parameters:

stream – The stream to write to. Defaults to stdout.

virtual ceres::LossFunction *lossFunction() const = 0

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.

virtual Loss::UniquePtr clone() const = 0

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

virtual void serialize(fuse_core::BinaryOutputArchive&) const = 0

Serialize this Loss into the provided binary archive.

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

archive << *this;

Parameters:

archive[out] - The archive to serialize this loss function into

virtual void serialize(fuse_core::TextOutputArchive&) const = 0

Serialize this Loss into the provided text archive.

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

archive << *this;

Parameters:

archive[out] - The archive to serialize this loss function into

virtual void deserialize(fuse_core::BinaryInputArchive&) = 0

Deserialize data from the provided binary archive into this Loss.

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

archive >> *this;

Parameters:

archive[in] - The archive holding serialized Loss data

virtual void deserialize(fuse_core::TextInputArchive&) = 0

Deserialize data from the provided text archive into this Loss.

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

archive >> *this;

Parameters:

archive[in] - The archive holding serialized Loss data

Public Static Attributes

static constexpr ceres::Ownership Ownership = ceres::Ownership::TAKE_OWNERSHIP

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

Friends

friend class boost::serialization::access