More tweaks.

This commit is contained in:
Naveen Sundar Govindarajulu 2017-01-22 11:29:26 -08:00
parent 8d5f2464a1
commit 5cc43e4b00
3 changed files with 19 additions and 15 deletions

View file

@ -6,6 +6,7 @@ import com.naveensundarg.shadow.prover.representations.value.Compound;
import com.naveensundarg.shadow.prover.representations.value.Value;
import com.naveensundarg.shadow.prover.representations.value.Variable;
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
import com.naveensundarg.shadow.prover.utils.Logic;
import com.naveensundarg.shadow.prover.utils.Sets;
import java.util.List;
@ -27,6 +28,7 @@ public class Action {
private final Formula precondition;
private int weight;
private final boolean trivial;
private final Compound shorthand;
@ -52,6 +54,8 @@ public class Action {
List<Value> valuesList = freeVariables.stream().collect(Collectors.toList());;
this.shorthand = new Compound(name, valuesList);
this.trivial = computeTrivialOrNot();
}
private Action(String name, Set<Formula> preconditions, Set<Formula> additions,
@ -78,6 +82,8 @@ public class Action {
deletions.stream().mapToInt(Formula::getWeight).sum();
this.shorthand = shorthand;
this.trivial = computeTrivialOrNot();
}
@ -139,12 +145,19 @@ public class Action {
return name;
}
public boolean isNonTrivial() {
return !trivial;
}
public boolean isNonTrivial(){
public boolean computeTrivialOrNot(){
boolean case1Trivial = Sets.subset(additions, preconditions) && deletions.isEmpty();
return !case1Trivial;
boolean case2Trivial = additions.isEmpty() && deletions.stream().allMatch(x->preconditions.stream().anyMatch(y->y.equals(Logic.negated(x))));
boolean trivial = case1Trivial || case2Trivial;
return trivial;
}
@Override
public String toString() {

View file

@ -1,11 +1,9 @@
package edu.rpi.rair;
import com.naveensundarg.shadow.prover.representations.formula.Formula;
import com.naveensundarg.shadow.prover.utils.CollectionUtils;
import com.naveensundarg.shadow.prover.utils.Pair;
import com.naveensundarg.shadow.prover.utils.Sets;
import javax.swing.text.html.Option;
import java.util.*;
import java.util.stream.Collectors;

View file

@ -32,7 +32,7 @@ public class RunDemo {
List<Problem> problems = ProblemReader.readFrom(Sandbox.class.getResourceAsStream("firstorder-completness-tests.clj"));
problems.forEach(problem -> {
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 10; i++) {
prover.prove(problem.getAssumptions(), problem.getGoal());
}
@ -88,7 +88,7 @@ public class RunDemo {
cp.clear();
cp.print(" ");
cp.setAttribute(Ansi.Attribute.BOLD);
cp.print((end - start) / 1000 + "s");
cp.print((end - start) / 1000.0 + "s");
@ -97,9 +97,8 @@ public class RunDemo {
public static void planningProblemWarmUp() throws Reader.ParsingException {
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 10; i++) {
System.out.println();
List<GoalTrackingProblem> goalTrackingProblemList = (GoalTrackingProblem.readFromFile(Planner.class.getResourceAsStream("goal_management_1.clj")));
@ -121,20 +120,14 @@ public class RunDemo {
goalTracker.adoptGoal(g1);
System.out.print(".");
goalTracker.adoptGoal(g2);
System.out.print(".");
goalTracker.adoptGoal(g3);
System.out.print(".");
goalTracker.adoptGoal(g4);
System.out.print(".");
goalTracker.adoptGoal(g5);