Adding context automaton
This commit is contained in:
31
rs.cc
31
rs.cc
@@ -168,3 +168,34 @@ void RctSys::printSystem(void)
|
|||||||
showReactions();
|
showReactions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CtxAut::hasState(std::string name)
|
||||||
|
{
|
||||||
|
if (states_names.find(name) == states_names.end())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::addState(std::string name)
|
||||||
|
{
|
||||||
|
if (!hasState(name))
|
||||||
|
{
|
||||||
|
State new_state_id = states_ids.size();
|
||||||
|
|
||||||
|
VERB_L2("Adding state: " << name << " index=" << new_state_id);
|
||||||
|
|
||||||
|
states_ids.push_back(name);
|
||||||
|
states_names[name] = new_state_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::pushContextEntity(std::string entityName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::addTransition(std::string srcStateName, std::string dstStateName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
156
rs.hh
156
rs.hh
@@ -24,91 +24,109 @@ using std::endl;
|
|||||||
|
|
||||||
class RctSys
|
class RctSys
|
||||||
{
|
{
|
||||||
friend class SymRS;
|
friend class SymRS;
|
||||||
friend class SymRSstate;
|
friend class SymRSstate;
|
||||||
friend class CtxAut;
|
public:
|
||||||
public:
|
typedef unsigned int Entity;
|
||||||
typedef unsigned int Entity;
|
typedef std::set<Entity> Entities;
|
||||||
typedef std::set<Entity> Entities;
|
struct Reaction {
|
||||||
struct Reaction {
|
Entities rctt;
|
||||||
Entities rctt;
|
Entities inhib;
|
||||||
Entities inhib;
|
Entities prod;
|
||||||
Entities prod;
|
};
|
||||||
};
|
typedef std::vector<Reaction> Reactions;
|
||||||
typedef std::vector<Reaction> Reactions;
|
typedef std::vector<std::string> EntitiesByIds;
|
||||||
typedef std::vector<std::string> EntitiesByIds;
|
typedef std::map<std::string, Entity> EntitiesByName;
|
||||||
typedef std::map<std::string, Entity> EntitiesByName;
|
typedef std::set<Entities> EntitiesSets;
|
||||||
typedef std::set<Entities> EntitiesSets;
|
private:
|
||||||
private:
|
Reactions reactions;
|
||||||
Reactions reactions;
|
EntitiesSets initStates;
|
||||||
EntitiesSets initStates;
|
|
||||||
|
|
||||||
Entities actionEntities;
|
Entities actionEntities;
|
||||||
|
|
||||||
EntitiesByIds entities_ids;
|
EntitiesByIds entities_ids;
|
||||||
EntitiesByName entities_names;
|
EntitiesByName entities_names;
|
||||||
|
|
||||||
Entities tmpReactants;
|
Entities tmpReactants;
|
||||||
Entities tmpInhibitors;
|
Entities tmpInhibitors;
|
||||||
Entities tmpProducts;
|
Entities tmpProducts;
|
||||||
|
|
||||||
Entities tmpState;
|
Entities tmpState;
|
||||||
|
|
||||||
Entity getEntityID(std::string entityName);
|
Entity getEntityID(std::string entityName);
|
||||||
|
|
||||||
Options *opts;
|
Options *opts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setOptions(Options *opts)
|
void setOptions(Options *opts)
|
||||||
{
|
{
|
||||||
this->opts = opts;
|
this->opts = opts;
|
||||||
}
|
}
|
||||||
bool hasEntity(std::string entityName);
|
bool hasEntity(std::string entityName);
|
||||||
void addEntity(std::string entityName);
|
void addEntity(std::string entityName);
|
||||||
std::string getEntityName(Entity entityID);
|
std::string getEntityName(Entity entityID);
|
||||||
void pushReactant(std::string entityName);
|
void pushReactant(std::string entityName);
|
||||||
void pushInhibitor(std::string entityName);
|
void pushInhibitor(std::string entityName);
|
||||||
void pushProduct(std::string entityName);
|
void pushProduct(std::string entityName);
|
||||||
void commitReaction(void);
|
void commitReaction(void);
|
||||||
std::string entityToStr(const Entity entity) {
|
std::string entityToStr(const Entity entity) {
|
||||||
return entities_ids[entity];
|
return entities_ids[entity];
|
||||||
}
|
}
|
||||||
std::string entitiesToStr(const Entities &entities);
|
std::string entitiesToStr(const Entities &entities);
|
||||||
void showReactions(void);
|
void showReactions(void);
|
||||||
void pushStateEntity(std::string entityName);
|
void pushStateEntity(std::string entityName);
|
||||||
void commitInitState(void);
|
void commitInitState(void);
|
||||||
void addActionEntity(std::string entityName);
|
void addActionEntity(std::string entityName);
|
||||||
bool isActionEntity(Entity entity);
|
bool isActionEntity(Entity entity);
|
||||||
void resetInitStates(void) {
|
void resetInitStates(void) {
|
||||||
initStates.clear();
|
initStates.clear();
|
||||||
}
|
}
|
||||||
unsigned int getEntitiesSize(void) {
|
unsigned int getEntitiesSize(void) {
|
||||||
return entities_ids.size();
|
return entities_ids.size();
|
||||||
}
|
}
|
||||||
unsigned int getReactionsSize(void) {
|
unsigned int getReactionsSize(void) {
|
||||||
return reactions.size();
|
return reactions.size();
|
||||||
}
|
}
|
||||||
unsigned int getActionsSize(void) {
|
unsigned int getActionsSize(void) {
|
||||||
return actionEntities.size();
|
return actionEntities.size();
|
||||||
}
|
}
|
||||||
void showInitialStates(void);
|
void showInitialStates(void);
|
||||||
void showActionEntities(void);
|
void showActionEntities(void);
|
||||||
void printSystem(void);
|
void printSystem(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RctSysWithCtxAut : private RctSys
|
class RctSysWithCtxAut : private RctSys
|
||||||
{
|
{
|
||||||
|
friend class CtxAut;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Context Automaton
|
// Context Automaton
|
||||||
class CtxAut
|
class CtxAut
|
||||||
{
|
{
|
||||||
typedef unsigned int State;
|
public:
|
||||||
typedef std::set<State> States;
|
typedef unsigned int State;
|
||||||
struct Transition {
|
typedef std::vector<std::string> StatesById;
|
||||||
State src_state;
|
typedef std::map<std::string, State> StatesByName;
|
||||||
State dst_state;
|
struct Transition {
|
||||||
};
|
State src_state;
|
||||||
|
RctSys::Entities ctx;
|
||||||
|
State dst_state;
|
||||||
|
};
|
||||||
|
bool hasState(std::string name);
|
||||||
|
void addState(std::string stateName);
|
||||||
|
void addTransition(std::string srcStateName, std::string dstStateName);
|
||||||
|
void pushContextEntity(std::string entityName);
|
||||||
|
void setOptions(Options *opts)
|
||||||
|
{
|
||||||
|
this->opts = opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Options *opts;
|
||||||
|
StatesById states_ids;
|
||||||
|
StatesByName states_names;
|
||||||
|
RctSys::Entities tmpEntities;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user