Skip to content

Commit

Permalink
add recursive rules
Browse files Browse the repository at this point in the history
  • Loading branch information
anacleto85 committed Apr 30, 2024
1 parent c9f981f commit 1056067
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>it.cnr.istc.pst</groupId>
<artifactId>platinum</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<packaging>jar</packaging>

<name>PLATINUm</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import it.cnr.istc.pst.platinum.ai.deliberative.solver.PseudoControllabilityAwareSolver;
import it.cnr.istc.pst.platinum.ai.deliberative.solver.SearchSpaceNode;
import it.cnr.istc.pst.platinum.ai.deliberative.solver.Solver;
import it.cnr.istc.pst.platinum.ai.deliberative.strategy.DepthFirstSearchStrategy;
import it.cnr.istc.pst.platinum.ai.deliberative.strategy.GreedyDepthSearchStrategy;
import it.cnr.istc.pst.platinum.ai.framework.domain.component.PlanDataBase;
import it.cnr.istc.pst.platinum.ai.framework.microkernel.FrameworkObject;
import it.cnr.istc.pst.platinum.ai.framework.microkernel.annotation.cfg.FrameworkLoggerConfiguration;
Expand All @@ -28,13 +28,17 @@
)
@FlawSelectionHeuristicsConfiguration(
heuristics = HierarchicalFlawSelectionHeuristic.class
// heuristics = ReverseHierarchicalFlawSelectionHeuristic.class
)
@SearchStrategyConfiguration(
strategy = DepthFirstSearchStrategy.class
// strategy = DepthFirstSearchStrategy.class
// strategy = StandardDeviationMinimizationSearchStrategy.class
strategy = GreedyDepthSearchStrategy.class
// strategy = WeightedAStarSearchStrategy.class
)
@FrameworkLoggerConfiguration(
// set logging level
level = FrameworkLoggingLevel.INFO
level = FrameworkLoggingLevel.DEBUG
)
public class Planner extends FrameworkObject {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import it.cnr.istc.pst.platinum.ai.deliberative.solver.SearchSpaceNode;
import it.cnr.istc.pst.platinum.ai.framework.domain.component.DomainComponent;
import it.cnr.istc.pst.platinum.ai.framework.microkernel.annotation.lifecycle.PostConstruct;

/**
*
Expand All @@ -20,11 +19,6 @@ protected GreedyDepthSearchStrategy() {
super("GreedyDepthSearchStrategy");
}

@PostConstruct
public void init() {

}

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import it.cnr.istc.pst.platinum.ai.framework.time.lang.query.IntervalScheduleQuery;
import it.cnr.istc.pst.platinum.ai.framework.time.solver.TemporalSolverType;
import it.cnr.istc.pst.platinum.ai.framework.time.tn.TemporalNetworkType;
import it.cnr.istc.pst.platinum.ai.framework.utils.properties.FilePropertyReader;

/**
*
Expand Down Expand Up @@ -103,6 +104,8 @@ public final class PlanDataBaseComponent extends DomainComponent implements Plan

// domain theory
private Map<String, ParameterDomain> parameterDomains;

private boolean allowRecursiveRules; // check if recursive rules are allowed

/**
*
Expand All @@ -115,10 +118,12 @@ public final class PlanDataBaseComponent extends DomainComponent implements Plan
protected PlanDataBaseComponent(String name)
{
super(name, DomainComponentType.PLAN_DATABASE);

// initialize data structures
this.components = new HashMap<>();
this.parameterDomains = new HashMap<>();
this.problem = null;
this.allowRecursiveRules = false; // default behavior
}

/**
Expand All @@ -145,6 +150,13 @@ protected synchronized void init() {
DecisionIdCounter.set(0);
// reset relation counter
RELATION_COUNTER.set(0);

// check property file
FilePropertyReader properties = new FilePropertyReader(
FRAMEWORK_HOME + FilePropertyReader.DEFAULT_DELIBERATIVE_PROPERTY);
// check property flag
this.allowRecursiveRules = properties.getProperty("allow-recursive-rules").equals("1");

}

/**
Expand Down Expand Up @@ -237,7 +249,12 @@ public synchronized void addSynchronizationRule(SynchronizationRule rule)
TokenVariable target = cons.getTarget();
if (!target.equals(existingRuleTrigger) && target.getValue().equals(value)) {
// we've got a cycle
throw new SynchronizationCycleException("A cycle has been detected after the introduction of synchronization rule " + rule);
warning("A cycle has been detected after the introduction of synchronization rule\n" + rule + "\n");
// check recursive rules flag
if (!this.allowRecursiveRules) {
// stop parsing on detected cycle
throw new SynchronizationCycleException("A cycle has been detected after the introduction of synchronization rule " + rule);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ public long getLowerBound() {
public long getUpperBound() {
return ub;
}

/*
*
*/
public String toString() {
return "Goal scheduling constraint " + this.left + " BEFORE " + this.right + "";
}
}

0 comments on commit 1056067

Please sign in to comment.