コード例 #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
ファイル: db_interface.cpp プロジェクト: sdevin/supervisor
/*
Function which send update to the database and update the mental states.
*/
void DBInterface::updateKnowledge(){

    //we send to the database the last update
    for(vector<supervisor_msgs::AgentKnowledge>::iterator it = toRemove_.begin(); it != toRemove_.end(); it++){
        removeFacts(it->knowledge, it->agentName);
    }
    toRemove_.clear();
    for(vector<supervisor_msgs::AgentKnowledge>::iterator it = toAdd_.begin(); it != toAdd_.end(); it++){
        addFacts(it->knowledge, it->agentName);
    }
    toAdd_.clear();

    //we get the last update from the database
    for(vector<supervisor_msgs::AgentKnowledge>::iterator it = knowledge_.begin(); it != knowledge_.end(); it++){
        it->knowledge = getFactsAgent(it->agentName);
    }

}
コード例 #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);

    }