|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPathPlan.MDP
public class MDP
A 2-dimensional MDP. Contains methods for managing per-state costs, converting between (x,y) pairs and state indices, and finding possible predecessors of a given state.
Field Summary | |
---|---|
int |
height
Size of the MDP. |
int |
width
Size of the MDP. |
Constructor Summary | |
---|---|
MDP(int w,
int h,
double c)
Constructor. |
Method Summary | |
---|---|
void |
addCost(int[] xs,
int[] ys,
int length,
double c)
Add a constant to the costs at a list of states. |
void |
clear()
Reset all edge costs to default. |
java.awt.Image |
getCostImage(double mincost,
double maxcost)
Return a grayscale image of the state costs. |
double[] |
getCosts()
Get the cost of every state as an array. |
double |
getDistance(int from,
int to)
Get the constant portion of the cost of moving in a straight line between states. |
double |
getLineCost(int startState,
int endState)
Accumulate total costs over a line. |
double |
getLineCost(int startState,
int endState,
double[] costs)
Accumulate total costs over a line. |
double |
getStepCost()
Get the per-step base cost. |
int |
getX(int index)
Get the x coordinate corresponding to a state index. |
int |
getY(int index)
Get the y coordinate corresponding to a state index. |
int |
numStates()
How many states do we have? |
int |
predBound()
Get a bound on the number of predecessors of a state. |
int |
predecessors(int state,
int distState,
boolean[] mask,
int[] preds,
double[] pcosts,
double[] dists)
Get information about the possible predecessors of a state. |
void |
set16connected()
Set to a 16-connected (5x5 actions, removing duplicate directions) grid |
void |
set8connected()
Set to an 8-connected (3x3 actions) grid |
void |
setCosts(double c)
Initialize to a constant cost per step. |
void |
setCosts(double[] c,
double baseCost)
Set the state costs for the MDP. |
void |
setStepCost(double c)
Set the per-step base cost. |
int |
stateIndex(int x,
int y)
Translate x, y into state index. |
int |
succBound()
Get a bound on the number of successors of a state. |
int |
successors(int state,
boolean[] mask,
int[] succs,
double[] scosts)
Get information about the possible successors of a state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int width
public int height
Constructor Detail |
---|
public MDP(int w, int h, double c)
Method Detail |
---|
public double[] getCosts()
public double getStepCost()
public void setStepCost(double c)
public void setCosts(double[] c, double baseCost)
c
- The cost vector. Should be numStates elements long.baseCost
- Additional cost per step beyond what's in c.public void setCosts(double c)
c
- The cost for a 1-unit step. (Some actions may move
more than 1 unit (e.g. diagonal moves have length sqrt(2)) and
so cost a multiple of this cost.)public void addCost(int[] xs, int[] ys, int length, double c)
xs
- The x coordinates of the states to modify.ys
- The y coordinates of the states to modify.length
- Use this many elements of xs and ys.c
- The cost increment.public void clear()
public java.awt.Image getCostImage(double mincost, double maxcost)
mincost
- Scale so that mincost is intensity 0.maxcost
- Scale so that maxcost is intensity 1.public void set8connected()
public void set16connected()
public double getLineCost(int startState, int endState)
startState
- Starting position.endState
- Ending position.public double getLineCost(int startState, int endState, double[] costs)
startState
- Starting position.endState
- Ending position.costs
- State costs.public double getDistance(int from, int to)
setCosts(double[], double)
.) This is faster to
compute than the full answer which getLineCost(int, int)
returns, and it is a lower bound under the assumption that all
costs are positive.
from
- Starting position.to
- Ending position.public int predBound()
public int succBound()
public final int successors(int state, boolean[] mask, int[] succs, double[] scosts)
state
- The state whose successors are required.mask
- Consider only successors s such that mask[s] is false.succs
- Store the successors in this array (which must be
preallocated large enough, see succBound).scosts
- Store the cost of each successor in this array
(which must be preallocated large enough, see succBound).public final int predecessors(int state, int distState, boolean[] mask, int[] preds, double[] pcosts, double[] dists)
state
- The state whose predecessors are required.distState
- If nonnegative, compute a lower bound on the
distance from each predecessor to distState and store in dists.mask
- Consider only predecessors p where mask[p]=true.preds
- Store the predecessors in this array (which must be
preallocated large enough -- see predBound)pcosts
- For each predecessor p, store the cost of reaching
state from p. (Must be preallocated also.)dists
- If distances were requested, store them in here.
(Must be preallocated also.)public int numStates()
public int stateIndex(int x, int y)
public int getX(int index)
public int getY(int index)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |