Beispiel #1
0
    Generator(const vd::DynamicsInit& init, const vd::InitEventList& events)
      : vd::Dynamics(init, events)
    {
        vg::ConnectionList my_list;

        // m_duration = vv::toDouble(events.get("duration"));
        m_duration = 0.1;
        if (events.end() != events.find("source_init_level")) {
            m_val = vv::toDouble(events.get("source_init_level"));
        } else {
            m_val = 1;
            Trace(6,
                  "Warning : Model %s got no init"
                  " output level (source_init_level) : assuming 1\n",
                  getModelName().c_str());
        }

        if (events.end() != events.find("source_trend")) {
            m_trend = vv::toDouble(events.get("source_trend"));
            if (events.end() != events.find("source_quantum")) {
                m_quantum = vv::toDouble(events.get("source_quantum"));
            } else {
                m_quantum = 0.01;
                Trace(6,
                      "Warning : Model %s got no output"
                      " quantum (source_quantum) : assuming 0.01\n",
                      getModelName().c_str());
            }
        } else {
            m_trend = 0;

            Trace(6,
                  "%s got no output trend (source_trend)"
                  " : assuming 0\n",
                  getModelName().c_str());

            // no trend => quantum is useless but..
            m_quantum = 0.01;
        }

        if (0 == m_quantum) {
            throw vu::ModellingError("Model %s has null output quantum.",
                                     getModelName().c_str());
        }

        m_has_output_port = false;
        my_list = getModel().getOutputPortList();

        if (my_list.size() > 0) {
            m_output_port_label = (my_list.begin())->first;
            m_has_output_port = true;
        }

        if (my_list.size() > 1) {
            Trace(6,
                  "Warning: multiple output ports."
                  " Will use only port %s\n",
                  m_output_port_label.c_str());
        }
    }
Beispiel #2
0
    AdaptativeQuantifier(const vd::DynamicsInit &init,
                         const vd::InitEventList &events)
        : vd::Dynamics(init, events)
    {
        const auto& my_list = getModel().getOutputPortList();

        if (not my_list.empty()) {
            m_output_port_label = (my_list.begin())->first;
            m_has_output_port = true;
        }

        if (my_list.size() > 1)
            Trace(context(), 6, "Warning: multiple output ports."
                  " Will use only port %s\n", m_output_port_label.c_str());

        m_adaptative = true;

        if (events.end() != events.find("allow_offsets")) {
            m_adaptative = vv::toBoolean(events.get("allow_offsets"));
        }

        if (m_adaptative) {
            m_adapt_state = POSSIBLE;
        } else {
            m_adapt_state = IMPOSSIBLE;
        }

        m_zero_init_offset = false;
        if (events.end() != events.find("zero_init_offset")) {
            m_zero_init_offset = vv::toBoolean(events.get("zero_init_offset"));
        }

        if (events.end() != events.find("quantum")) {
            m_step_size = vv::toDouble(events.get("quantum"));
        } else {
            Trace(context(), 6, "Warning : no quantum value provided for"
                  " Quantifier %s. Using default value (0.1)\n",
                  getModelName().c_str());

            m_step_size = 0.1;
        }

        if (0 >= m_step_size)
            throw vu::ModellingError("Bad quantum value (provided value : %f, "
                                     "should be strictly positive)",
                                     m_step_size);

        if (events.end() != events.find("archive_length")) {
            m_past_length = vv::toInteger(events.get("archive_length"));
        } else {
            m_past_length = 3;
        }

        if (2 >= m_past_length) {
            throw vu::ModellingError("Bad archive length value ( provided value"
                ": %u, should at least 3)", m_past_length);
        }
    }