Пример #1
0
    KnowledgeBase()
        : vmd::KnowledgeBase(), mNbUpdate(0), mNbAck(0), mNbOut(0)
    {
        addFacts(this) +=
            F("fact 1", &KnowledgeBase::updateFact1),
            F("fact 2", &KnowledgeBase::updateFact2);

        addPredicates(this) +=
            P("pred 1", &KnowledgeBase::isAlwaysTrue),
            P("pred 2", &KnowledgeBase::isAlwaysTrue),
            P("pred 3", &KnowledgeBase::isAlwaysTrue),
            P("pred 4", &KnowledgeBase::isAlwaysTrue),
            P("pred 5", &KnowledgeBase::isAlwaysTrue),
            P("pr ed 5", &KnowledgeBase::isAlwaysTrue),
            P("pred 6", &KnowledgeBase::isAlwaysTrue),
            P("pred 7", &KnowledgeBase::isAlwaysFalse);

        addOutputFunctions(this) +=
            O("output function", &KnowledgeBase::out);

        addAcknowledgeFunctions(this) +=
            A("ack function", &KnowledgeBase::ack);

        addUpdateFunctions(this) +=
            U("update function", &KnowledgeBase::update);
    }
Пример #2
0
    KB5() :
        vmd::KnowledgeBase(), mNbUpdate(0), mNbAck(0), mNbOut(0)
    {
        std::cout << fmt("KB5 start\n");
        vmd::Activity& a = addActivity("A", 0.0, vd::infinity);
        vmd::Activity& b = addActivity("B", 1.0, vd::infinity);
        vmd::Activity& c = addActivity("C", 1.0, vd::infinity);
        vmd::Activity& d = addActivity("D", 2.0, vd::infinity);
        vmd::Activity& e = addActivity("E", 3.0, vd::infinity);
        vmd::Activity& f = addActivity("F", 4.0, vd::infinity);

        addOutputFunctions(this) += O("out", &KB5::out);
        addUpdateFunctions(this) += U("update", &KB5::update);

        a.addOutputFunction(outputFunctions()["out"]);
        b.addOutputFunction(outputFunctions()["out"]);
        c.addOutputFunction(outputFunctions()["out"]);
        d.addOutputFunction(outputFunctions()["out"]);
        e.addOutputFunction(outputFunctions()["out"]);
        f.addOutputFunction(outputFunctions()["out"]);

        a.addUpdateFunction(updateFunctions()["update"]);
        b.addUpdateFunction(updateFunctions()["update"]);
        c.addUpdateFunction(updateFunctions()["update"]);
        d.addUpdateFunction(updateFunctions()["update"]);
        e.addUpdateFunction(updateFunctions()["update"]);
        f.addUpdateFunction(updateFunctions()["update"]);
    }
Пример #3
0
    Smartgardener(
        const vd::DynamicsInit& init,
        const vd::InitEventList& evts)
        : vmd::Agent(init, evts),
          plantlouse_population(0),
          ladybird_population(0),
          treatment_effect_on_plantlouse(0),
          treatment_effect_on_ladybird(0),
          plantlouse_max_population(1000),
          ladybird_min_population(-1000)
    {
        treatment_effect_on_plantlouse =
                evts.getDouble("treatment_effect_on_plantlouse");
        treatment_effect_on_ladybird =
                evts.getDouble("treatment_effect_on_ladybird");
        plantlouse_max_population =
                evts.getDouble("plantlouse_max_population");
        ladybird_min_population =
                evts.getDouble("ladybird_min_population");

        addPredicates(this) +=
                P("TwoManyPlantlouse", &Smartgardener::TwoManyPlantlouse),
                P("NotToSmallLadybirdPopulation",
                        &Smartgardener::NotToSmallLadybirdPopulation);

        addFacts(this) +=
                F("x", &Smartgardener::x),
                F("y", &Smartgardener::y);

        addOutputFunctions(this) +=
                O("treat", &Smartgardener::treat);

        vle::utils::Package pack(context(), "vle.examples");
        std::string filePath = pack.getDataFile("Smartgardener.txt");
        std::ifstream fileStream(filePath.c_str());
        KnowledgeBase::plan().fill(fileStream);

    }