6#ifndef YARP_MANAGER_BINEXPARSER
7#define YARP_MANAGER_BINEXPARSER
34 sprintf(str,
"%s%d", opd,
node_id++);
45 sprintf(str,
"%s%d", opt,
node_id++);
81 const char*
getName() {
return strName.c_str(); }
100 bool parse(std::string _exp);
104 validOperands.push_back(opnd);
117 bool evalTree(
BinaryNodePtr node, std::map<std::string, bool>& opnd);
119 bool checkExpression(std::string& strexp);
120 void parseExpression(std::string &strexp,
BinaryNodePtr& node);
123 std::string getNextOperand(std::string &strexp);
124 std::string popNextOperand(std::string &strexp);
125 void createTruthTable(
const int n);
126 void printTruthTable(std::string lopr);
130 std::string expression;
134 std::map<std::string, bool> operands;
135 std::vector<std::string> validOperands;
136 std::vector<std::string> invalidOperands;
137 std::vector<std::vector<int> > truthTable;
147 maxIteration(max_itr),
148 trainRate(train_rate),
154 bool train(
const std::vector<std::vector<int> > &truthTable);
156 const std::vector<double> &
getAlphas() {
return alphas; }
157 const std::vector<double> &
getErrors() {
return errors; }
163 std::vector<double> alphas;
164 std::vector<double> errors;
const std::vector< std::vector< int > > & getTruthTable()
virtual ~BinaryExpParser()
void addRestrictedOperand(const char *opnd)
bool parse(std::string _exp)
const std::map< std::string, bool > & getOperands()
bool exportDotGraph(const char *szFileName)
~BinaryNode() override=default
BinaryNode(const char *opd)
BinaryNode(const char *opt, BinaryNode *left, BinaryNode *right)
bool train(const std::vector< std::vector< int > > &truthTable)
const std::vector< double > & getErrors()
LinkTrainer(int max_itr=1000, double train_rate=1.0)
const std::vector< double > & getAlphas()
Link & getLinkAt(int index)
bool addSuc(Node *node, float weight, bool _virtual=false)
class Node
void setLabel(const char *szLabel)
BinaryNode * BinaryNodePtr
enum yarp::manager::__BinNodeType BinNodeType
enum yarp::manager::__NodeType NodeType