Search Results for

    Show / Hide Table of Contents

    Class observe::Observer

    Inheritance
    utils::ComponentWithOutput
    observe::Observer
    solver::Solver
    Inherited Members
    set_output_parameter
    set_output_parameter
    param
    get_output_parameters
    ~Component
    Component
    get_status
    get_class_name

    Constructors

    Observer()

    Declaration
    observe::Observer::Observer()

    Methods

    restart()

    Declaration
    void observe::Observer::restart(size_t step)

    is_watching()

    Declaration
    bool observe::Observer::is_watching(const std::string&identifier) const

    set_observable_label()

    Declaration
    void observe::Observer::set_observable_label(const std::string&identifier, const T&value)

    clear_observable_label()

    Declaration
    void observe::Observer::clear_observable_label(const std::string&identifier)

    scoped_observable_label()

    Declaration
    ScopedLabel observe::Observer::scoped_observable_label(const std::string&label, T value)

    observe()

    Declaration
    void observe::Observer::observe(const std::string&identifier, double value, double weight=1.0)

    configure()

    configure the object from input

    Initialize the object's state from the input utils::Config. This is done by declaring which required and optional parameters are associated with the fields of this object. During initialization, they are checked for their presence, type and any matchers. Example:

    MyClass : public Component {
     public:
      void configure(const utils::Json& json) override {
        this->param(json, "number", my_number)
            .description("some description")
            .matches(GreaterEquals(0))
            .required();
        this->param(json, "name", my_name)
            .description("some description")
            .matches(SizeIs(GreaterThan(0)))
            .default_value("no_name");
      }
    
     private:
      int my_number;
      std::string my_name;
    }
    
    MyClass my_object;
    my_object.configure(utils::json_from_string(R"(
      {
        "number": 42,
        "name": "hello"
      }
    )"));
    
    Note

    By default, nothing is configured from input. You need to overload this method if you want to use this functionality. Don't forget to call the configure method of the parent class if it also needs to be configured (this is not the case for utils::Component itself). HINT: Parameters are not limited to scalars and strings; Any component can be a parameter; in which case it is initialized using its own configure method. utils::Json

    Declaration
    void observe::Observer::configure(const utils::Json&json) override

    render()

    render the object in structured form

    Return a structured representation of the object. This is intended for output purposes. For instance, the solution your solver finds should have a render method which allows it to be returned as part of the result. Example:

    {c++}
     MySolution : public Component {
      public:
       // Represent the internal bool vector as +-1 output.
       utils::Structure render() const override {
         utils::Structure rendered;
         for (bool item : solution_) rendered.push_back(item ? 1 : -1);
         return rendered;
       }
    
      private:
       std::vector<bool> solution_;
     }
    
     MySolution solution;
     std::cout << solution.render().to_string() << std::endl;
    

    utils::Structure

    Declaration
    utils::Structure observe::Observer::render() const override
    In This Article
    Back to top Generated with Doxygen and DocFX