public class StateGridder
extends java.lang.Object
setObjectClassAttributesToTile(String, burlap.behavior.singleagent.auxiliary.StateGridder.AttributeSpecification...)
.
That method takes as input the object class, and the list of StateGridder.AttributeSpecification
objects. Each StateGridder.AttributeSpecification
object specifies the name
of an attribute, the lower limit value that the grid spans, the upper limit value that the grid spans, and how many grid points
will exist along that dimension. If you simply want a even number of grid points across the entire domain
of attributes for an ObjectClass
or all ObjectClass
objects,
consider using instead the gridEntireObjectClass(burlap.oomdp.core.ObjectClass, int)
} or
gridEntireDomainSpace(burlap.oomdp.core.Domain, int)
methods.
After the desired grid specifications have been set, a list of states spanning a grid according to the specification
can be generated using the gridInputState(burlap.oomdp.core.states.State)
method. This method takes a source input
state and creates a grid from it. Objects classes and attributes that did not have grid specifications
defined for them will remain as constant objects/values in each of the returned states. The input state values
will remain unaffected by the gridding.
Note that this gridder only works with attributes that are Attribute.AttributeType.REAL
Example usage with the MountainCar
domain below.
MountainCar mc = new MountainCar();
Domain domain = mc.generateDomain();
State s = mc.getCleanState(domain);
gridder.gridEntireDomainSpace(domain, 3);
List<State> gridStates = gridder.gridInputState(s);
System.out.println("Num states: " + gridStates.size());
for(State g : gridStates){
System.out.println(g.toString());
}
Alternatively, you may replace the grid specification with something more specific; e.g., to create a 4x3 grid:
gridder.setObjectClassAttributesToTile(MountainCar.CLASSAGENT,
new AttributeSpecification(domain.getAttribute(MountainCar.ATTX), 4),
new AttributeSpecification(domain.getAttribute(MountainCar.ATTV), 3),
Modifier and Type | Class and Description |
---|---|
static class |
StateGridder.AttributeSpecification
Class for specifying the grid along a single attribute.
|
Constructor and Description |
---|
StateGridder() |
Modifier and Type | Method and Description |
---|---|
void |
gridEntireDomainSpace(Domain domain,
int numGridPointsPerAttribute)
Grids an entire domain; that is each
ObjectClass associated with the domain will have each of its
associated Attributes gridded (each spanning the specified number of grid points). |
void |
gridEntireObjectClass(ObjectClass obClass,
int numGridPointsPerAttribute)
Grids an entire Object class object with each of its associated attributes having the grid span their whole domain
with the same number of grid points.
|
java.util.List<State> |
gridInputState(State s)
Creates a grid using the input state a source reference.
|
void |
setObjectClassAttributesToTile(java.lang.String objectClassName,
StateGridder.AttributeSpecification... attSpecs)
Sets the attribute specifications to use for a single
ObjectClass |
public void setObjectClassAttributesToTile(java.lang.String objectClassName, StateGridder.AttributeSpecification... attSpecs)
ObjectClass
objectClassName
- the name of the ObjectClass
attSpecs
- the StateGridder.AttributeSpecification
objects defining how each attribute is gridded.public void gridEntireObjectClass(ObjectClass obClass, int numGridPointsPerAttribute)
obClass
- the ObjectClass
to gridnumGridPointsPerAttribute
- the number of grid points along each Attribute
associated with the ObjectClass
.public void gridEntireDomainSpace(Domain domain, int numGridPointsPerAttribute)
ObjectClass
associated with the domain will have each of its
associated Attributes gridded (each spanning the specified number of grid points).domain
- the Domain
to grid.numGridPointsPerAttribute
- the number of grid points per attributepublic java.util.List<State> gridInputState(State s)
ObjectClass
that are not defined in this object's grid specification, that each of those objects will be constant objects in the gridded list
of State
objects returned. Similarly, if objects have attribute that do not have a specification set for them,
then they will remain as constant values.s
- the input state to use a reference for creating the grid. This state specifies the number of objects that needed to be gridded and any constant ungridded objects/attributesList
of State
objects that define the grid.