mirror of
https://github.com/RAIRLab/Spectra.git
synced 2024-11-24 09:56:30 -05:00
Handling edge cases in precondition -> formula
This commit is contained in:
parent
492e7bac14
commit
a747b38233
2 changed files with 11 additions and 1 deletions
|
@ -49,7 +49,14 @@ public class Action {
|
||||||
|
|
||||||
this.freeVariables = freeVariables;
|
this.freeVariables = freeVariables;
|
||||||
|
|
||||||
|
if (preconditions.size() > 1) {
|
||||||
this.precondition = new And(preconditions.stream().collect(Collectors.toList()));
|
this.precondition = new And(preconditions.stream().collect(Collectors.toList()));
|
||||||
|
} else if (preconditions.size() == 1) {
|
||||||
|
this.precondition = preconditions.iterator().next();
|
||||||
|
} else {
|
||||||
|
this.precondition = State.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.weight = preconditions.stream().mapToInt(Formula::getWeight).sum() +
|
this.weight = preconditions.stream().mapToInt(Formula::getWeight).sum() +
|
||||||
additions.stream().mapToInt(Formula::getWeight).sum() +
|
additions.stream().mapToInt(Formula::getWeight).sum() +
|
||||||
|
|
|
@ -12,14 +12,17 @@ import java.util.Set;
|
||||||
public class State {
|
public class State {
|
||||||
|
|
||||||
final Set<Formula> formulae;
|
final Set<Formula> formulae;
|
||||||
|
static Formula TRUE;
|
||||||
static Formula FALSE;
|
static Formula FALSE;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
TRUE = Reader.readFormulaFromString("(or P (not P))");
|
||||||
FALSE = Reader.readFormulaFromString("(and P (not P))");
|
FALSE = Reader.readFormulaFromString("(and P (not P))");
|
||||||
} catch (Reader.ParsingException e) {
|
} catch (Reader.ParsingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
TRUE = null;
|
||||||
FALSE = null;
|
FALSE = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue