diff --git a/build.gradle b/build.gradle index 9ba3dae0..2f8abfe9 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ description = "CST is the Cognitive Systems Toolkit, a toolkit for the construct sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = '0.5.1' +version = '0.6.0' repositories { flatDir { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 622ab64a..b9fe08c3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed Sep 09 22:32:12 BRT 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/br/unicamp/cst/planning/PlanningCodelet.java b/src/main/java/br/unicamp/cst/planning/PlanningCodelet.java new file mode 100644 index 00000000..9c5ce39f --- /dev/null +++ b/src/main/java/br/unicamp/cst/planning/PlanningCodelet.java @@ -0,0 +1,80 @@ +package br.unicamp.cst.planning; + +import br.unicamp.cst.core.entities.Codelet; +import br.unicamp.cst.core.entities.Memory; +import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException; + +import java.util.Optional; + +public abstract class PlanningCodelet extends Codelet { + + private String id; + + private Memory inputInitialState; + + private Memory inputObservations; + + private Memory inputGoals; + + private Memory inputProceduralMemory; + + private Memory inputTransitionFunctions; + + private Memory inputPlanningRequest; + + private Memory outputPlan; + + public PlanningCodelet(String id) { + setId(id); + } + + @Override + public void accessMemoryObjects() { + inputInitialState = Optional.ofNullable(inputInitialState) + .orElse(getInput(PlanningMemoryNames.INPUT_INITIAL_STATE.toString())); + + inputObservations = Optional.ofNullable(inputObservations) + .orElse(getInput(PlanningMemoryNames.INPUT_OBSERVATIONS.toString())); + + inputGoals = Optional.ofNullable(inputGoals) + .orElse(getInput(PlanningMemoryNames.INPUT_GOALS.toString())); + + inputProceduralMemory = Optional.ofNullable(inputProceduralMemory) + .orElse(getInput(PlanningMemoryNames.INPUT_PROCEDURAL_MEMORY.toString())); + + inputTransitionFunctions = Optional.ofNullable(inputTransitionFunctions) + .orElse(getInput(PlanningMemoryNames.INPUT_TRANSITION_FUNCTIONS.toString())); + + inputPlanningRequest = Optional.ofNullable(inputPlanningRequest) + .orElse(getInput(PlanningMemoryNames.INPUT_PLANNING_REQUEST.toString())); + + outputPlan = Optional.ofNullable(outputPlan) + .orElse(getInput(PlanningMemoryNames.OUTPUT_PLAN.toString())); + } + + @Override + public void calculateActivation() { + try { + setActivation(0d); + } catch (CodeletActivationBoundsException e) { + e.printStackTrace(); + } + } + + @Override + public void proc() { + Optional.ofNullable(outputPlan).ifPresent(memory -> { + memory.setI(planning(inputInitialState, inputObservations, inputGoals, inputProceduralMemory, inputTransitionFunctions, inputPlanningRequest).getI()); + }); + } + + public abstract Memory planning(Memory initialState, Memory observations, Memory goals, Memory proceduralMemory, Memory transitionFunctions, Memory planningRequest); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/br/unicamp/cst/planning/PlanningMemoryNames.java b/src/main/java/br/unicamp/cst/planning/PlanningMemoryNames.java new file mode 100644 index 00000000..4b6b4822 --- /dev/null +++ b/src/main/java/br/unicamp/cst/planning/PlanningMemoryNames.java @@ -0,0 +1,11 @@ +package br.unicamp.cst.planning; + +public enum PlanningMemoryNames { + INPUT_INITIAL_STATE, + INPUT_OBSERVATIONS, + INPUT_GOALS, + INPUT_PROCEDURAL_MEMORY, + INPUT_TRANSITION_FUNCTIONS, + INPUT_PLANNING_REQUEST, + OUTPUT_PLAN +}