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);
        }
    }
    TimeSlicingMethod(DifferentialEquation& eq,
            const vd::InitEventList& events) :
            DifferentialEquationImpl(eq, events), devs_state(INIT),
            devs_options(), devs_guards(), devs_internal(),
            int_method(*this, events)
    {
        if (events.exist("output_period")) {
            const value::Value& v = *(events.get("output_period"));
            devs_options.output_period = 0;
            if (v.isInteger()) {
                devs_options.output_period = v.toInteger().value();
            }
            if (devs_options.output_period < 1) {
                throw utils::ModellingError(vle::utils::format(
                        "[%s] Parameter 'output_period' should be an int > 0",
                        getModelName().c_str()));
            }
        }
        if (events.exist("time_step")) {
            devs_options.dt = events.getDouble("time_step");
            if (devs_options.dt <= 0) {
                throw utils::ModellingError(vle::utils::format(
                        "[%s] Parameter 'time_step' should be > 0",
                        getModelName().c_str()));
            }
        }

    }
Beispiel #4
0
 XRay::XRay(const vd::DynamicsInit& init, const vd::InitEventList& events)
     : vd::Dynamics(init, events)
 {
   mProbabilityRightSR = vv::toDouble(events.get("probabilityRightSR"));
   mProbabilityRightI = vv::toDouble(events.get("probabilityRightI"));
   mObservationTimeStep =  vv::toDouble(events.get("timeStep"));
   if (events.exist("R_INIT") and 
       (vv::toBoolean(events.get("R_INIT")))) {
       mNbModel =vv::toInteger(events.get("graphInfo_number"));
       mPrefix =vv::toString(events.get("graphInfo_prefix"));
   } else {
       mNbModel = events.getMap("graphInfo").getInt("number");
       mPrefix = events.getMap("graphInfo").getString("prefix");
   }
   mSampleSize = /*boost::lexical_cast<int>*/ (vv::toDouble(events.get("echProp")) * mNbModel);
   //std::cout<<"smplesize= "<<mSampleSize<<"\n";
   mPrevalence=0.; mIncidence=0.;
     }
Beispiel #5
0
 ActivityScheduler(const vle::devs::DynamicsInit& init,
                   const vle::devs::InitEventList& events) :
     vle::devs::Dynamics(init, events),
     mActivities(events.get("activities"))
 {
 }