4.1.5. Model¶
-
class
primitiv::
Model
¶ Set of parameters and specific algorithms.
Inherits from primitiv::mixins::Nonmovable< Model >
Public Functions
-
void
load
(const std::string &path, bool with_stats, Device *device)¶ Loads all parameters from a file.
- Parameters
path
: Path of the file.with_stats
: Whether or not to load all additional statistics.device
: Device object to manage parameters.
-
void
load
(const std::string &path, bool with_stats, Device &device)¶ Loads all parameters from a file.
- Parameters
path
: Path of the file.with_stats
: Whether or not to load all additional statistics.device
: Device object to manage parameters.
-
void
load
(const std::string &path, bool with_stats)¶ Loads all parameters from a file.
- Parameters
path
: Path of the file.with_stats
: Whether or not to load all additional statistics.
-
void
load
(const std::string &path)¶ Loads all parameters from a file.
- Parameters
path
: Path of the file.
-
void
save
(const std::string &path, bool with_stats) const¶ Saves all parameters to a file.
- Parameters
path
: Path of the file.with_stats
: Whether or not to save all additional statistics.
-
void
save
(const std::string &path) const¶ Saves all parameters to a file.
- Parameters
path
: Path of the file.
-
void
add
(const std::string &name, Parameter ¶m)¶ Registers a new parameter.
- Remark
name
should not be overlapped with all registered parameters and submodels.- Parameters
name
: Name of the parameter.param
: Reference to the parameter.
-
void
add
(const std::string &name, Model &model)¶ Registers a new submodel.
- Remark
name
should not be overlapped with all registered parameters and submodels.- Parameters
name
: Name of the submodel.model
: Reference to the submodel.
-
const Parameter &
get_parameter
(const std::string &name) const¶ Retrieves a parameter with specified name.
-
const Parameter &
get_parameter
(const std::vector<std::string> &names) const¶ Recursively searches a parameter with specified name hierarchy.
-
Parameter &
get_parameter
(const std::vector<std::string> &names)¶ Recursively searches a parameter with specified name hierarchy.
-
const Parameter &
get_parameter
(const std::initializer_list<std::string> names) const¶ Recursively searches a parameter with specified name hierarchy.
-
Parameter &
get_parameter
(const std::initializer_list<std::string> names)¶ Recursively searches a parameter with specified name hierarchy.
-
const Model &
get_submodel
(const std::string &name) const¶ Retrieves a submodel with specified name.
- Return
- Const-reference of the corresponding
Model
object. - Parameters
name
: Name of the submodel.
- Exceptions
primitiv::Error
: Submodel withname
not found.
-
Model &
get_submodel
(const std::string &name)¶ Retrieves a submodel with specified name.
- Return
- Reference of the corresponding
Model
object. - Parameters
name
: Name of the submodel.
- Exceptions
primitiv::Error
: Submodel withname
not found.
-
const Model &
get_submodel
(const std::vector<std::string> &names) const¶ Recursively searches a submodel with specified name hierarchy.
- Return
- Const-reference of the corresponding
Model
object. - Parameters
names
: Name hierarchy of the submodel.
- Exceptions
primitiv::Error
: Submodel withnames
not found.
-
Model &
get_submodel
(const std::vector<std::string> &names)¶ Recursively searches a submodel with specified name hierarchy.
- Return
- Const-reference of the corresponding
Model
object. - Parameters
names
: Name hierarchy of the submodel.
- Exceptions
primitiv::Error
: Submodel withnames
not found.
-
const Model &
get_submodel
(const std::initializer_list<std::string> names) const¶ Recursively searches a submodel with specified name hierarchy.
- Return
- Const-reference of the corresponding
Model
object. - Parameters
names
: Name hierarchy of the submodel.
- Exceptions
primitiv::Error
: Submodel withnames
not found.
-
Model &
get_submodel
(const std::initializer_list<std::string> names)¶ Recursively searches a submodel with specified name hierarchy.
- Return
- Const-reference of the corresponding
Model
object. - Parameters
names
: Name hierarchy of the submodel.
- Exceptions
primitiv::Error
: Submodel withnames
not found.
-
void