45#define G_ACCESS "GModels::operator[](std::string&)"
46#define G_AT "GModels::at(int&)"
47#define G_SET1 "GModels::set(int&, GModel&)"
48#define G_SET2 "GModels::set(std::string&, GModel&)"
49#define G_APPEND "GModels::append(GModel&)"
50#define G_INSERT1 "GModels::insert(int&, GModel&)"
51#define G_INSERT2 "GModels::insert(std::string&, GModel&)"
52#define G_REMOVE1 "GModels::remove(int&)"
53#define G_REMOVE2 "GModels::remove(std::string&)"
54#define G_EXTEND "GModels::extend(GModels&)"
55#define G_READ "GModels::read(GXml&)"
150 if (
this != &models) {
185 std::string msg =
"Model \""+name+
"\" not found in model container. "
186 "Please specify the name of an available model.";
212 std::string msg =
"Model \""+name+
"\" not found in model container. "
213 "Please specify the name of an available model.";
272 #if defined(G_RANGE_CHECK)
273 if (index < 0 || index >=
size()) {
296 #if defined(G_RANGE_CHECK)
297 if (index < 0 || index >=
size()) {
324 #if defined(G_RANGE_CHECK)
325 if (index < 0 || index >=
size()) {
332 if (inx != -1 && inx != index) {
334 "Attempt to set model with name \""+model.
name()+
"\" in model "
335 "container at index "+
gammalib::str(index)+
", but a model with "
337 " in the container. Every model in the model container needs a "
377 std::string msg =
"Model \""+name+
"\" not found in model container. "
378 "Please specify the name of an available model.";
384 if (inx != -1 && inx != index) {
386 "Attempt to set model with name \""+model.
name()+
"\" in model"
387 " container at index "+
gammalib::str(index)+
", but a model with"
388 " the same name exists already at index "+
gammalib::str(inx)+
389 " in the container.\n"
390 "Every model in the model container needs a unique name.";
426 "Attempt to append model with name \""+model.
name()+
"\" to model"
427 " container, but a model with the same name exists already at"
429 " Every model in the model container needs a unique name.";
462 #if defined(G_RANGE_CHECK)
470 if (index < 0 || index >=
size()) {
481 "Attempt to insert model with name \""+model.
name()+
"\" in model"
482 " container before index "+
gammalib::str(index)+
", but a model"
483 " with the same name exists already at index "+
gammalib::str(inx)+
484 " in the container.\n"
485 "Every model in the model container needs a unique name.";
522 std::string msg =
"Model \""+name+
"\" not found in model container. "
523 "Please specify the name of an available model.";
531 "Attempt to insert model with name \""+model.
name()+
"\" in model"
532 " container before index "+
gammalib::str(index)+
", but a model"
533 " with the same name exists already at index "+
gammalib::str(inx)+
534 " in the container.\n"
535 "Every model in the model container needs a unique name.";
563 #if defined(G_RANGE_CHECK)
564 if (index < 0 || index >=
size()) {
598 std::string msg =
"Model \""+name+
"\" not found in model container. "
599 "Please specify the name of an available model.";
629 int num = models.
size();
635 for (
int i = 0; i < num; ++i) {
641 "Attempt to append model with name \""+models[i]->name()+
642 "\" to model container, but a model with the same name"
645 "Every model in the model container needs a unique name.";
676 return (index != -1);
721 for (
int i = 0; i <
size(); ++i) {
780 for (
int i = 0; i < n; ++i) {
786 std::string type = src->
attribute(
"type");
799 std::string msg =
"Model type \""+type+
"\" unknown. The following "
800 "model types are available: "+registry.
content()+
801 ". Please specify one of the available model "
831 if (xml.
elements(
"source_library") == 0) {
839 for (
int i = 0; i <
size(); ++i) {
859 for (
int i = 0; i <
size(); ++i) {
884 for (
int i = 0; i <
size(); ++i) {
887 for (
int k = 0; k <
npars; ++k) {
913 const bool& gradients)
const
919 for (
int i = 0; i <
size(); ++i) {
921 value +=
m_models[i]->eval(event, obs, gradients);
953 for (
int i = 0; i <
size(); ++i) {
955 values +=
m_models[i]->eval(obs, gradients);
981 result.append(
"=== GModels ===");
990 for (
int i = 0; i <
size(); ++i) {
1033 for (
int i = 0; i < models.
m_models.size(); ++i) {
1051 for (
int i = 0; i <
m_models.size(); ++i) {
1076 for (
int i = 0; i <
size(); ++i) {
Exception handler interface definition.
Filename class interface definition.
Sparse matrix class definition.
Model registry class definition.
Abstract model base class interface definition.
Model container class definition.
Abstract observation base class interface definition.
Optimizer parameters base class definition.
Vector class interface definition.
XML element node class interface definition.
XML class interface definition.
Abstract interface for the event classes.
virtual int size(void) const =0
std::string url(void) const
Return Uniform Resource Locator (URL)
Sparse matrix class interface definition.
Interface definition for the model registry class.
GModel * alloc(const std::string &name) const
Allocate model of given name.
virtual void read(const GXmlElement &xml)=0
int size(void) const
Return number of parameters in model.
virtual GModel * clone(void) const =0
Clones object.
const std::string & name(void) const
Return parameter name.
void save(const GFilename &filename) const
Save models into XML file.
GModel * insert(const int &index, const GModel &model)
Insert model into container.
bool contains(const std::string &name) const
Signals if model name exists.
bool is_empty(void) const
Signals if there are no models in container.
void free_members(void)
Delete class members.
GModel * at(const int &index)
Return pointer to model.
void clear(void)
Clear object.
void load(const GFilename &filename)
Load models from XML file.
GOptimizerPars pars(void) const
Return optimizer parameter container.
int get_index(const std::string &name) const
Return model index by name.
void write(GXml &xml) const
Write models into XML document.
GModels(void)
Void constructor.
GModels & operator=(const GModels &models)
Assignment operator.
int size(void) const
Return number of models in container.
GModel * set(const int &index, const GModel &model)
Set model in container.
std::vector< GModel * > m_models
List of models.
GModels * clone(void) const
Clone instance.
GModel * operator[](const int &index)
Return pointer to model.
void read(const GXml &xml)
Read models from XML document.
int npars(void) const
Return number of model parameters in container.
void remove(const int &index)
Remove model from container.
std::string print(const GChatter &chatter=NORMAL) const
Print models.
double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate sum of all models.
GModel * append(const GModel &model)
Append model to container.
void init_members(void)
Initialise class members.
virtual ~GModels(void)
Destructor.
void extend(const GModels &models)
Append model container.
void reserve(const int &num)
Reserves space for models in container.
void copy_members(const GModels &models)
Copy class members.
Abstract observation base class.
virtual GEvents * events(void)
Return events.
virtual std::string instrument(void) const =0
void id(const std::string &id)
Set observation identifier.
Optimizer parameter container class.
void attach(GOptimizerPar *par)
Attach parameter to container.
std::string content(void) const
Return list of names in registry.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
Abstract XML node base class.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual int elements(void) const
Return number of GXMLElement children of node.
void save(const GFilename &filename) const
Save XML document into file.
GXmlElement * element(const int &index)
Return pointer to child element.
GXmlNode * append(const GXmlNode &node)
Append child node to XML document root.
int elements(void) const
Return number of child elements in XML document root.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.