本文整理汇总了Java中burlap.mdp.core.state.State.get方法的典型用法代码示例。如果您正苦于以下问题:Java State.get方法的具体用法?Java State.get怎么用?Java State.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类burlap.mdp.core.state.State
的用法示例。
在下文中一共展示了State.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flatStatesEqual
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
protected boolean flatStatesEqual(State s1, State s2){
if(s1 == s2){
return true;
}
List<Object> keys1 = s1.variableKeys();
List<Object> keys2 = s2.variableKeys();
if(keys1.size() != keys2.size()){
return false;
}
for(Object key : keys1){
Object v1 = s1.get(key);
Object v2 = s2.get(key);
if(!this.valuesEqual(key, v1, v2)){
return false;
}
}
return true;
}
示例2: paint
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public void paint(Graphics2D g2, State s,
float cWidth, float cHeight) {
//agent will be filled in gray
g2.setColor(Color.GRAY);
//set up floats for the width and height of our domain
float fWidth = ExampleGridWorld.this.map.length;
float fHeight = ExampleGridWorld.this.map[0].length;
//determine the width of a single cell on our canvas
//such that the whole map can be painted
float width = cWidth / fWidth;
float height = cHeight / fHeight;
int ax = (Integer) s.get(VAR_X);
int ay = (Integer) s.get(VAR_Y);
//left coordinate of cell on our canvas
float rx = ax * width;
//top coordinate of cell on our canvas
//coordinate system adjustment because the java canvas
//origin is in the top left instead of the bottom right
float ry = cHeight - height - ay * height;
//paint the rectangle
g2.fill(new Ellipse2D.Float(rx, ry, width, height));
}
示例3: paint
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public void paint(Graphics2D g2, State s,
float cWidth, float cHeight) {
//agent will be filled in gray
g2.setColor(Color.GRAY);
//set up floats for the width and height of our domain
float fWidth = ExampleGridWorld.this.map.length;
float fHeight = ExampleGridWorld.this.map[0].length;
//determine the width of a single cell on our canvas
//such that the whole map can be painted
float width = cWidth / fWidth;
float height = cHeight / fHeight;
int ax = (Integer)s.get(VAR_X);
int ay = (Integer)s.get(VAR_Y);
//left coordinate of cell on our canvas
float rx = ax*width;
//top coordinate of cell on our canvas
//coordinate system adjustment because the java canvas
//origin is in the top left instead of the bottom right
float ry = cHeight - height - ay*height;
//paint the rectangle
g2.fill(new Ellipse2D.Float(rx, ry, width, height));
}
示例4: reward
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public double reward(State s, Action a, State sprime) {
int ax = (Integer)s.get(VAR_X);
int ay = (Integer)s.get(VAR_Y);
//are they at goal location?
if(ax == this.goalX && ay == this.goalY){
return 100.;
}
return -1;
}
示例5: isTerminal
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public boolean isTerminal(State s) {
//get location of agent in next state
int ax = (Integer)s.get(VAR_X);
int ay = (Integer)s.get(VAR_Y);
//are they at goal location?
if(ax == this.goalX && ay == this.goalY){
return true;
}
return false;
}
示例6: computeFlatHashCode
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
protected int computeFlatHashCode(State s){
HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(17, 31);
List<Object> keys = s.variableKeys();
for(Object key : keys){
Object value = s.get(key);
this.appendHashCodeForValue(hashCodeBuilder, key, value);
}
return hashCodeBuilder.toHashCode();
}
示例7: move
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
/**
* Changes the agents position in the provided state using car engine acceleration in the specified direction.
* dir=+1 indicates forward acceleration; -1 backwards acceleration; 0 no acceleration (coast).
* @param s the state in which the agents position should be modified
* @param dir the direction of acceleration
* @return the modified state s
*/
public State move(State s, int dir){
double p0 = (Double)s.get(ATT_X);
double v0 = (Double)s.get(ATT_V);
double netAccel = (physParams.acceleration * dir) - (physParams.gravity * Math.cos(physParams.cosScale*p0));
double v1 = v0 + physParams.timeDelta * netAccel;
if(v1 < physParams.vmin){
v1 = physParams.vmin;
}
else if(v1 > physParams.vmax){
v1 = physParams.vmax;
}
double p1 = p0 + physParams.timeDelta*v1; //original mechanics in paper defined this way
//double p1 = p0 + this.timeDelta*v0 + .5*netAccel*this.timeDelta*this.timeDelta; //more accurate estimate
if(p1 < physParams.xmin){
p1 = physParams.xmin;
v1 = 0.;
}
else if(p1 > physParams.xmax){
p1 = physParams.xmax;
v1 = 0.;
}
((MutableState)s).set(ATT_X, p1);
((MutableState)s).set(ATT_V, v1);
return s;
}
示例8: sample
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public State sample(State s, Action a) {
s = s.copy();
int aId = ((GraphActionType.GraphAction)a).aId;
int n = (Integer)s.get(VAR);
Map<Integer, Set<NodeTransitionProbability>> actionMap = transitionDynamics.get(n);
Set<NodeTransitionProbability> transitions = actionMap.get(aId);
double roll = rand.nextDouble();
double sumP = 0.;
int selection = 0;
for(NodeTransitionProbability ntp : transitions){
sumP += ntp.probability;
if(roll < sumP){
selection = ntp.transitionTo;
break;
}
}
((MutableState)s).set(VAR, selection);
return s;
}
示例9: applicableInState
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
protected boolean applicableInState(State s){
int n = (Integer)s.get("node");
Map<Integer, Set<NodeTransitionProbability>> actionMap = transitionDynamics.get(n);
Set<NodeTransitionProbability> transitions = actionMap.get(aId);
if(transitions == null){
return false;
}
if(transitions.isEmpty()){
return false;
}
return true;
}
示例10: sample
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public State sample(State state, Action action){
//override for faster sampling
if(action.actionName().equals(TigerDomain.ACTION_LEFT) || action.actionName().equals(TigerDomain.ACTION_RIGHT)){
return this.observationReset();
}
else if(action.actionName().equals(TigerDomain.ACTION_LISTEN)){
String tigerVal = (String)state.get(TigerDomain.VAR_DOOR);
double r = RandomFactory.getMapped(0).nextDouble();
if(r < this.listenAccuracy){
if(tigerVal.equals(TigerDomain.VAL_LEFT)){
return this.observationLeft();
}
else{
return this.observationRight();
}
}
else{
//then nosiy listen; reverse direction
if(tigerVal.equals(TigerDomain.VAL_LEFT)){
return this.observationRight();
}
else{
return this.observationLeft();
}
}
}
else if(action.actionName().equals(TigerDomain.ACTION_DO_NOTHING)){
return this.observationNothing();
}
throw new RuntimeException("Unknown action " + action.actionName() + "; cannot return observation sample.");
}
示例11: paint
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public void paint(Graphics2D g2, State s, float cWidth, float cHeight) {
double worldWidth = physParams.xmax - physParams.xmin;
double renderAgentWidth = 0.04*cWidth;
double ox = (Double)s.get(ATT_X);
double oy = Math.sin(this.physParams.cosScale*ox);
double nx = (ox - this.physParams.xmin) / worldWidth;
double ny = (oy + 1) / 2;
double sx = (nx * cWidth) - (renderAgentWidth / 2);
double sy = cHeight - (ny * (cHeight-30)+15) - (renderAgentWidth / 2);
g2.setColor(Color.red);
g2.fill(new Rectangle2D.Double(sx, sy, renderAgentWidth, renderAgentWidth));
}
示例12: stateTransitions
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public List<StateTransitionProb> stateTransitions(State s, Action a) {
int aId = ((GraphActionType.GraphAction)a).aId;
List <StateTransitionProb> result = new ArrayList<StateTransitionProb>();
int n = (Integer)s.get(VAR);
Map<Integer, Set<NodeTransitionProbability>> actionMap = transitionDynamics.get(n);
Set<NodeTransitionProbability> transitions = actionMap.get(aId);
for(NodeTransitionProbability ntp : transitions){
State ns = s.copy();
((MutableState)ns).set(VAR, ntp.transitionTo);
StateTransitionProb tp = new StateTransitionProb(ns, ntp.probability);
result.add(tp);
}
return result;
}
示例13: probability
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public double probability(State observation, State state,
Action action) {
String oVal = (String)observation.get(TigerDomain.VAR_HEAR);
String tigerVal = (String)state.get(TigerDomain.VAR_DOOR);
if(action.actionName().equals(TigerDomain.ACTION_LEFT) || action.actionName().equals(TigerDomain.ACTION_RIGHT)){
if(oVal.equals(TigerDomain.DOOR_RESET)){
return 1.;
}
return 0.;
}
if(action.actionName().equals(TigerDomain.ACTION_LISTEN)){
if(tigerVal.equals(TigerDomain.VAL_LEFT)){
if(oVal.equals(TigerDomain.HEAR_LEFT)){
return this.listenAccuracy;
}
else if(oVal.equals(TigerDomain.HEAR_RIGHT)){
return 1.-this.listenAccuracy;
}
else{
return 0.;
}
}
else{
if(oVal.equals(TigerDomain.HEAR_LEFT)){
return 1.-this.listenAccuracy;
}
else if(oVal.equals(TigerDomain.HEAR_RIGHT)){
return this.listenAccuracy;
}
else{
return 0.;
}
}
}
//otherwise we're in the noop
if(action.actionName().equals(TigerDomain.ACTION_DO_NOTHING)){
if(oVal.equals(TigerDomain.HEAR_NOTHING)){
return 1.;
}
else{
return 0.;
}
}
throw new RuntimeException("Unknown action " + action.actionName() + "; cannot return observation probability.");
}
示例14: isTerminal
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public boolean isTerminal(State s) {
double x = (Double)s.get(ATT_X);
return x >= threshold;
}
示例15: paintStateValue
import burlap.mdp.core.state.State; //导入方法依赖的package包/类
@Override
public void paintStateValue(Graphics2D g2, State s, double value, float cWidth, float cHeight) {
Number x = (Number)s.get(xKey);
Number y = (Number)s.get(yKey);
float xval;
float yval;
float width;
float height;
width = cWidth / (float)(xRange.span() / xWidth);
height = cHeight / (float)(yRange.span() / yWidth);
float normX = (float)xRange.norm(x.doubleValue());
xval = normX * cWidth;
float normY = (float)yRange.norm(y.doubleValue());
yval = cHeight - height - normY*cHeight;
Color col = this.colorBlend.color(value);
g2.setColor(col);
g2.fill(new Rectangle2D.Float(xval, yval, width, height));
if(this.renderValueString){
g2.setColor(this.vsFontColor);
g2.setFont(new Font("sansserif", Font.BOLD, this.vsFontSize));
String fstring = String.format("%."+this.vsPrecision+"f", value);
float sxval = xval + this.vsOffsetFromLeft*width;
float syval = yval + this.vsOffsetFromTop*height;
g2.drawString(fstring, sxval, syval);
}
}