Skip to content

Commit

Permalink
Reformat the files
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonChern committed Dec 9, 2022
1 parent c543c35 commit 89c2abb
Show file tree
Hide file tree
Showing 12 changed files with 932 additions and 883 deletions.
10 changes: 5 additions & 5 deletions src/algorithms/gfd/const_literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

class ConstLiteral : public Literal {
public:
ConstLiteral(std::pair<int, std::string> node, std::string value) {
this->vars.push_back(node.first);
ConstLiteral(std::pair<int, std::string> node, std::string value) {
this->vars.push_back(node.first);

this->values.push_back(node.second);
this->values.push_back(value);
}
this->values.push_back(node.second);
this->values.push_back(value);
}
};
56 changes: 29 additions & 27 deletions src/algorithms/gfd/gfd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@
#include "gfd.h"

void GFD::print() const {
this->pattern.print();
std::cout << std::endl << "Premises: ";
for (const Literal& l : this->premises) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1) << "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "="
<< vars.at(1) << "." << values.at(1) << "; ";
}
}
std::cout << std::endl << "=>" << std::endl << "Conclusion: ";
for (const Literal& l : this->conclusion) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1) << "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "="
<< vars.at(1) << "." << values.at(1) << "; ";
}
}
this->pattern.print();
std::cout << std::endl << "Premises: ";
for (const Literal &l : this->premises) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1)
<< "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << vars.at(1) << "."
<< values.at(1) << "; ";
}
}
std::cout << std::endl << "=>" << std::endl << "Conclusion: ";
for (const Literal &l : this->conclusion) {
std::vector<int> vars = l.getVars();
std::vector<std::string> values = l.getValues();
if (vars.size() == 1) {
// ConstLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << values.at(1)
<< "; ";
} else {
// VarLiteral
std::cout << vars.at(0) << "." << values.at(0) << "=" << vars.at(1) << "."
<< values.at(1) << "; ";
}
}
}
21 changes: 12 additions & 9 deletions src/algorithms/gfd/gfd.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#pragma once
#include <vector>

#include "pattern.h"
#include "literal.h"
#include "pattern.h"

class GFD {
private:
Pattern pattern;
std::vector<Literal> premises;
std::vector<Literal> conclusion;
Pattern pattern;
std::vector<Literal> premises;
std::vector<Literal> conclusion;

public:
GFD(Pattern& pattern_, std::vector<Literal>& premises_, std::vector<Literal>& conclusion_) : pattern(pattern_), premises(premises_), conclusion(conclusion_) {}
GFD(Pattern &pattern_, std::vector<Literal> &premises_,
std::vector<Literal> &conclusion_)
: pattern(pattern_), premises(premises_), conclusion(conclusion_) {}

Pattern getPattern() const { return this->pattern; }
std::vector<Literal> getPremises() const { return this->premises; }
std::vector<Literal> getConclusion() const { return this->conclusion; }
Pattern getPattern() const { return this->pattern; }
std::vector<Literal> getPremises() const { return this->premises; }
std::vector<Literal> getConclusion() const { return this->conclusion; }

void print() const;
void print() const;
};
Loading

0 comments on commit 89c2abb

Please sign in to comment.