当前位置: 首页>>代码示例>>C++>>正文


C++ ExternalEventList::size方法代码示例

本文整理汇总了C++中vle::devs::ExternalEventList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ExternalEventList::size方法的具体用法?C++ ExternalEventList::size怎么用?C++ ExternalEventList::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vle::devs::ExternalEventList的用法示例。


在下文中一共展示了ExternalEventList::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: externalTransition

    virtual void externalTransition(const vd::ExternalEventList &events,
                                    vd::Time time) override
    {
        double val, shifting_factor;
        int cnt;

        if (events.size() > 1)
            Trace(context(), 6, "Warning: %s got multiple events at date: %f\n",
                  getModelName().c_str(), time);

        auto it = events.begin();
        while (it != events.end()) {
            val = it->getMap().getDouble("d_val");
            if (INIT == m_state) {
                init_step_number_and_offset(val);
                update_thresholds();
                m_state = RESPONSE;
            } else {
                cnt = 0;
                if ((val > m_upthreshold) || (val < m_downthreshold))
                    Trace(context(), 6, "%s: treating out of bonds val: %f "
                          "(quantizer interval : [%f,%f] at date: %f",
                          getModelName().c_str(), val, m_downthreshold,
                          m_upthreshold, time);

                while ((val >= m_upthreshold) || (val <= m_downthreshold)) {
                    cnt++;
                    if (val >= m_upthreshold) {
                        m_step_number++;
                    } else {
                        m_step_number--;
                    }
                    switch (m_adapt_state) {
                    case IMPOSSIBLE:
                        update_thresholds();
                        break;
                    case POSSIBLE:
                        if (val >= m_upthreshold) {
                            store_change(m_step_size, time);
                        } else {
                            store_change(-m_step_size, time);
                        }
                        shifting_factor = shift_quanta();
                        if (0 > shifting_factor)
                            throw vu::ModellingError(
                                "Bad shifting value (value : %f, "
                                "should be strictly positive)\n",
                                 shifting_factor);
                        if (1 < shifting_factor)
                            throw vu::ModellingError(
                                "Bad shifting value ( value : %f, "
                                "should be less than 1)\n",
                                shifting_factor);;
                        if ((0 != shifting_factor) && (1 != shifting_factor)) {
                            if (val >= m_upthreshold) {
                                update_thresholds(shifting_factor, DOWN);
                            } else {
                                update_thresholds(shifting_factor, UP);
                            }
                            Trace(context(), 6,
                                  "Quantifier %s new quantas while treating new val %f at date %f",
                                  getModelName().c_str(), val, time);

                            Trace(context(), 6,
                                  "Quantizer interval:  [%f, %f], amplitude: %f "
                                  "(default amplitude: %f)", m_downthreshold,
                                  m_upthreshold, (m_upthreshold - m_downthreshold),
                                  (2 * m_step_size));

                            Trace(context(), 6,
                                  "Quantifier %s shifting : %f",
                                  getModelName().c_str(), shifting_factor);

                            m_adapt_state = DONE;
                        } else {
                            update_thresholds();
                        }
                        break;
                    case DONE: // equiv to reinit
                        init_step_number_and_offset(val);
                        // archive.resize(0);
                        m_adapt_state = POSSIBLE;
                        update_thresholds();
                        break;
                    }
                }

                if (cnt > 1)
                    Trace(context(), 6, "Warning : in %s multiple quanta change"
                          " at date : %f %d\n", getModelName().c_str(), time, cnt);

                if (0 == cnt)
                    Trace(context(), 6, "Warning : in %s useless ext transition"
                          "call: no quanta change! input val %f (quantizer "
                          "interval : [%f,%f] at date %f\n", getModelName().c_str(),
                          val, m_downthreshold, m_upthreshold, time);
            }
            ++it;
        }
        m_state = RESPONSE;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的vle::devs::ExternalEventList::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。