-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planning codelet #16
base: master
Are you sure you want to change the base?
Planning codelet #16
Changes from 5 commits
f3640f3
21b0ff0
877394e
716235a
fc63c92
d98dc1e
4bebbd2
ec5a589
5e4c058
0b9b51b
2609b29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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; | ||
|
||
public abstract class PlanningCodelet extends Codelet { | ||
|
||
private String id; | ||
|
||
private Memory inputInitialStateMO; | ||
|
||
private Memory inputGoalsMO; | ||
private Memory inputActionsMO; | ||
private Memory inputTransitionFunctionsMO; | ||
|
||
private Memory outputPlanMO; | ||
|
||
public PlanningCodelet(String id) { | ||
setId(id); | ||
} | ||
|
||
@Override | ||
public void accessMemoryObjects() { | ||
if(inputInitialStateMO == null | ||
&& inputGoalsMO == null | ||
&& inputActionsMO == null | ||
&& inputTransitionFunctionsMO == null | ||
&& outputPlanMO == null | ||
){ | ||
inputInitialStateMO = getInput(PlanningMemoryNames.INPUT_INITIAL_STATE_MEMORY.toString()); | ||
inputGoalsMO = getInput(PlanningMemoryNames.INPUT_GOALS_MEMORY.toString()); | ||
inputActionsMO = getInput(PlanningMemoryNames.INPUT_ACTIONS_MEMORY.toString()); | ||
inputTransitionFunctionsMO = getInput(PlanningMemoryNames.INPUT_TRANSITION_FUNCTIONS_MEMORY.toString()); | ||
outputPlanMO = getOutput(PlanningMemoryNames.OUTPUT_PLAN_MEMORY.toString()); | ||
} | ||
} | ||
|
||
@Override | ||
public void calculateActivation() { | ||
try { | ||
setActivation(0d); | ||
} catch (CodeletActivationBoundsException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void proc() { | ||
outputPlanMO.setI(planning(inputInitialStateMO, inputGoalsMO, inputActionsMO).getI()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me, but without a test that can be used also as a spec to this Codelet, it becomes quite hard to understand how all these abstract concepts should be used in practice. What do you think of adding a test to this PR, so anyone would have it as a spec for how to use this new PlanningCodelet? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. André I will implement tests using planning codelet in this PR, but I haven't had time to do that yet. |
||
} | ||
|
||
public abstract Memory planning(Memory currentState, Memory goal, Memory actions); | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package br.unicamp.cst.planning; | ||
|
||
public enum PlanningMemoryNames { | ||
INPUT_INITIAL_STATE_MEMORY, | ||
INPUT_GOALS_MEMORY, | ||
INPUT_ACTIONS_MEMORY, | ||
INPUT_TRANSITION_FUNCTIONS_MEMORY, | ||
OUTPUT_PLAN_MEMORY | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the Semantic Versioning 2.0.0 that we have been using, I recommend this PR to bump CST's version to
0.6.0
, as we effectively have a new feature here.