summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-07-10 13:02:28 +1000
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-07-10 13:02:28 +1000
commiteaca4d39f176acbcc567d0cb18dd9fb6c92ad60d (patch)
tree9c4da52ed0af6484963d61b3477463c621604d10
parentf9fc35785b53aa097a09ab1b865d33497ee1802e (diff)
A few other changes that were needed for tests
I must have forgotten to commit them earlier. How annoying.
-rw-r--r--impl/EquationSystem.g1
-rw-r--r--impl/TODO.org9
-rw-r--r--impl/main.cpp17
3 files changed, 14 insertions, 13 deletions
diff --git a/impl/EquationSystem.g b/impl/EquationSystem.g
index 3a6598a..07e8e71 100644
--- a/impl/EquationSystem.g
+++ b/impl/EquationSystem.g
@@ -30,6 +30,7 @@ expr : '(' expr GREATER_EQUAL expr QUESTION_MARK expr ')' -> ^(GUARD expr expr e
term : NUMBER
| VARIABLE
+ | '-'^ term
| '('! expr ')'! ;
diff --git a/impl/TODO.org b/impl/TODO.org
index 4d14b64..a33f685 100644
--- a/impl/TODO.org
+++ b/impl/TODO.org
@@ -33,14 +33,15 @@
- [ ] info
print the initial system we're working with
-* TODO make test [0/4]
-- [ ] write test cases [/]
+* TODO make test [2/4]
+- [-] write test cases [1/4]
+ - [X] examples from paper
- [ ] best cases
- [ ] worst cases
- [ ] average cases
- [ ] work out correct outputs for each test case
-- [ ] write a script to run over each test case and return pass/fail
-- [ ] consolidate into makefile as `make test`
+- [X] write a script to run over each test case and return pass/fail
+- [X] consolidate into makefile as `make test`
* TODO Parametrise EquationSystem for Variable, too [0/1]
- [ ] Give EquationSystem a template parameter for Variable
diff --git a/impl/main.cpp b/impl/main.cpp
index 726fa3e..2b7a9a1 100644
--- a/impl/main.cpp
+++ b/impl/main.cpp
@@ -98,7 +98,7 @@ void treeToSystem(pANTLR3_BASE_TREE node, EquationSystem<T>& system) {
typedef Complete<int> ZBar;
int main (int argc, char* argv[]) {
if (argc <= 3) {
- cout << "Usage: " << argv[0] << " filename fixpoint strategy [log]" << endl
+ cerr << "Usage: " << argv[0] << " filename fixpoint strategy [log]" << endl
<< " fixpoint: naive | smart" << endl
<< " strategy: naive | repeat | smart" << endl
<< " log: section[,section[,section[...]]]" << endl;
@@ -135,12 +135,12 @@ int main (int argc, char* argv[]) {
FixpointAlgorithm<ZBar>* algorithm = NULL;
if (!strcmp(argv[2], "naive")) {
algorithm = new NaiveFixpointAlgorithm<ZBar>(system);
- cout << "Naive fixpoint" << endl;
+ log::info << "Naive fixpoint" << endl;
} else if (!strcmp(argv[2], "smart")) {
algorithm = new SmartFixpointAlgorithm<ZBar>(system);
- cout << "Smart fixpoint" << endl;
+ log::info << "Smart fixpoint" << endl;
} else {
- cout << "Unknown fixpoint algorithm." << endl;
+ cerr << "Unknown fixpoint algorithm." << endl;
}
// PARSE ARGUMENTS - strat improvement
@@ -148,15 +148,15 @@ int main (int argc, char* argv[]) {
ImprovementOperator<ZBar>* improvement = NULL;
if (!strcmp(argv[3], "repeat")) {
improvement = new RepeatedImprovementOperator<ZBar>(*naiveImprovement);
- cout << "Repeated strategy improvement" << endl;
+ log::info << "Repeated strategy improvement" << endl;
} else if (!strcmp(argv[3], "naive")) {
improvement = naiveImprovement;
- cout << "Naive strategy improvement" << endl;
+ log::info << "Naive strategy improvement" << endl;
} else if (!strcmp(argv[3], "smart")) {
improvement = new SmartImprovementOperator<ZBar>(system);
- cout << "Smart strategy improvement" << endl;
+ log::info << "Smart strategy improvement" << endl;
} else {
- cout << "Unknown strategy improvement algorithm." << endl;
+ cerr << "Unknown strategy improvement algorithm." << endl;
}
if (!improvement || !algorithm) {
exit(1);
@@ -182,7 +182,6 @@ int main (int argc, char* argv[]) {
log::debug << "Changed: " << (changed ? "true" : "false") << std::endl;
} while(changed);
- cout << endl;
for (unsigned int i = 0, size = system.variableCount(); i < size; ++i) {
Variable<ZBar>& var = system.variable(i);
cout << var.name() << " = " << result[var] << endl;