public void setUp() { oneBoard = new NQueensBoard(1); eightBoard = new NQueensBoard(8); af = NQueensFunctionFactory.getIActionsFunction(); rf = NQueensFunctionFactory.getResultFunction(); }
/** * Constructs an online search problem with the specified action function, * goal test, and a default step cost function. * * @param actionsFunction * ACTIONS(s), which returns a list of actions allowed in state s * @param goalTest * GOAL-TEST(s), which the agent can apply to a single state * description to determine if it is a goal state */ public OnlineSearchProblem(ActionsFunction actionsFunction, GoalTest goalTest) { this.actionsFunction = actionsFunction; this.goalTest = goalTest; this.stepCostFunction = new DefaultStepCostFunction(); }
public Problem(Object initialState, ActionsFunction actionsFunction, ResultFunction resultFunction, GoalTest goalTest) : this(initialState, actionsFunction, resultFunction, goalTest, new DefaultStepCostFunction()) { }
/** * Constructs an online search problem with the specified action function, * goal test, and a default step cost function. * * @param actionsFunction * ACTIONS(s), which returns a list of actions allowed in state s * @param goalTest * GOAL-TEST(s), which the agent can apply to a single state * description to determine if it is a goal state * @param stepCostFunction * the step-cost function c(s, a, s') - note that this cannot be * used until the agent knows that s' is the outcome */ public OnlineSearchProblem(ActionsFunction actionsFunction, GoalTest goalTest, StepCostFunction stepCostFunction) { this.actionsFunction = actionsFunction; this.goalTest = goalTest; this.stepCostFunction = stepCostFunction; }
public static ActionsFunction getActionsFunction() { if (null == _actionsFunction) { _actionsFunction = new EPActionsFunction(); } return(_actionsFunction); }
/** * Returns an ACTIONS function for the incremental formulation of the * n-queens problem. */ public static ActionsFunction getIActionsFunction() { if (null == _iActionsFunction) { _iActionsFunction = new NQIActionsFunction(); } return(_iActionsFunction); }
public static ActionsFunction getActionsFunction() { if (null == _actionsFunction) { _actionsFunction = new EPActionsFunction(); } return _actionsFunction; }
/** * Returns an ACTIONS function for the complete-state formulation of the * n-queens problem. */ public static ActionsFunction getCActionsFunction() { if (null == _cActionsFunction) { _cActionsFunction = new NQCActionsFunction(); } return _cActionsFunction; }
/** * Returns an ACTIONS function for the incremental formulation of the * n-queens problem. */ public static ActionsFunction getIActionsFunction() { if (null == _iActionsFunction) { _iActionsFunction = new NQIActionsFunction(); } return _iActionsFunction; }
/** * Returns an ACTIONS function for the complete-state formulation of the * n-queens problem. */ public static ActionsFunction getCActionsFunction() { if (null == _cActionsFunction) { _cActionsFunction = new NQCActionsFunction(); } return(_cActionsFunction); }
public Problem(Object initialState, ActionsFunction actionsFunction, ResultFunction resultFunction, GoalTest goalTest, StepCostFunction stepCostFunction) { this.initialState = initialState; this.actionsFunction = actionsFunction; this.resultFunction = resultFunction; this.goalTest = goalTest; this.stepCostFunction = stepCostFunction; }
/** * Constructs a problem with the specified components, which includes a step * cost function. * * @param initialState * the initial state of the agent. * @param actionsFunction * a description of the possible actions available to the agent. * @param resultFunction * a description of what each action does; the formal name for * this is the transition model, specified by a function * RESULT(s, a) that returns the state that results from doing * action a in state s. * @param goalTest * test determines whether a given state is a goal state. * @param stepCostFunction * a path cost function that assigns a numeric cost to each path. * The problem-solving-agent chooses a cost function that * reflects its own performance measure. */ public Problem(Object initialState, ActionsFunction actionsFunction, ResultFunction resultFunction, GoalTest goalTest, StepCostFunction stepCostFunction) { this.initialState = initialState; this.actionsFunction = actionsFunction; this.resultFunction = resultFunction; this.goalTest = goalTest; this.stepCostFunction = stepCostFunction; }
public void setUp() { ExtendableMap aMap = new ExtendableMap(); aMap.addBidirectionalLink("A", "B", 5.0); aMap.addBidirectionalLink("A", "C", 6.0); aMap.addBidirectionalLink("B", "C", 4.0); aMap.addBidirectionalLink("C", "D", 7.0); aMap.addUnidirectionalLink("B", "E", 14.0); af = MapFunctionFactory.getActionsFunction(aMap); rf = MapFunctionFactory.getResultFunction(); }
public MDP(Set <S> states, S initialState, ActionsFunction <S, A> actionsFunction, TransitionProbabilityFunction <S, A> transitionProbabilityFunction, RewardFunction <S> rewardFunction) { this._states = states; this.initialState = initialState; this.actionsFunction = actionsFunction; this.transitionProbabilityFunction = transitionProbabilityFunction; this.rewardFunction = rewardFunction; }
/** * Returns the allowed actions from a specified cell within the cell world * described in Fig 17.1. * * @param cw * the cell world from figure 17.1. * @return the set of actions allowed at a particular cell. This set will be * empty if at a terminal state. */ public static ActionsFunction <Cell <Double>, CellWorldAction> createActionsFunctionForFigure17_1( CellWorld <Double> cw) { Set <Cell <Double> > terminals = new Set <Cell <Double> >(); terminals.add(cw.getCellAt(4, 3)); terminals.add(cw.getCellAt(4, 2)); ActionsFunction <Cell <Double>, CellWorldAction> af = null; //new ActionsFunction<Cell<Double>, CellWorldAction>() { //}; // TODO return(af); }
public Problem GetProblem(Object owner, IContextLookup globalVars, Object initialState) { Problem toReturn; var objActionsFunction = ActionsFunction.EvaluateTyped(owner, globalVars); var objResultFunction = ResultFunction.EvaluateTyped(owner, globalVars); var objGoalTest = GoalTest.EvaluateTyped(owner, globalVars); if (StepCostFunction.Enabled) { var objStepCostFunction = StepCostFunction.Entity.EvaluateTyped(owner, globalVars); toReturn = new Problem(initialState, objActionsFunction, objResultFunction, objGoalTest, objStepCostFunction); } else { toReturn = new Problem(initialState, objActionsFunction, objResultFunction, objGoalTest); } return(toReturn); }
public List <Node> expandNode(Node node, Problem problem) { List <Node> childNodes = new List <Node>(); ActionsFunction actionsFunction = problem.getActionsFunction(); ResultFunction resultFunction = problem.getResultFunction(); StepCostFunction stepCostFunction = problem.getStepCostFunction(); foreach (Action action in actionsFunction.actions(node.getState())) { System.Object successorState = resultFunction.result(node.getState(), action); double stepCost = stepCostFunction.c(node.getState(), action, successorState); childNodes.Add(new Node(successorState, node, action, stepCost)); } metrics.set(METRIC_NODES_EXPANDED, metrics .getInt(METRIC_NODES_EXPANDED) + 1); return(childNodes); }
/** * Returns the children obtained from expanding the specified node in the * specified problem. * * @param node * the node to expand * @param problem * the problem the specified node is within. * * @return the children obtained from expanding the specified node in the * specified problem. */ public List <Node> expand(Node node, Problem problem) { List <Node> successors = new List <Node>(); ActionsFunction actionsFunction = problem.getActionsFunction(); ResultFunction resultFunction = problem.getResultFunction(); StepCostFunction stepCostFunction = problem.getStepCostFunction(); foreach (Action action in actionsFunction.actions(node.State)) { System.Object successorState = resultFunction.result(node.State, action); double stepCost = stepCostFunction.c(node.State, action, successorState); successors.Add(createNode(successorState, node, action, stepCost)); } foreach (NodeListener listener in nodeListeners) { listener.onNodeExpanded(node); } counter++; return(successors); }
public OnlineSearchProblem(ActionsFunction actionsFunction, GoalTest goalTest) { this(actionsFunction, goalTest, new DefaultStepCostFunction()); }
/** * Constructs a problem with the specified components, and a default step * cost function (i.e. 1 per step). * * @param initialState * the initial state that the agent starts in. * @param actionsFunction * a description of the possible actions available to the agent. * @param resultFunction * a description of what each action does; the formal name for * this is the transition model, specified by a function * RESULT(s, a) that returns the state that results from doing * action a in state s. * @param goalTest * test determines whether a given state is a goal state. */ public Problem(Object initialState, ActionsFunction actionsFunction, ResultFunction resultFunction, GoalTest goalTest) : this(initialState, actionsFunction, resultFunction, goalTest, new DefaultStepCostFunction()) { }