Options
All
  • Public
  • Public/Protected
  • All
Menu

The abstract class for a formal problem. You should subclass this and implement the methods actions and result, and possibly init, goal_test, and path_cost. Then you will create instances of your subclass and solve them with the various search functions.

export

Type parameters

  • T

Hierarchy

Constructors

Properties

Methods

Constructors

constructor

  • new Problem<T>(initial: T, goal?: undefined | T): Problem<T>

Creates an instance of Problem. The constructor specifies the initial state, and possibly a goal state, if there is a unique goal. Your subclass' constructor can add other arguments.

Type parameters

  • T

Parameters

  • initial: T
  • goal: undefined | T = ...

Returns Problem<T>

Properties

goal

goal: undefined | T | T []

initial

initial: T | T []

Methods

action

  • action(_state: T): never

Return the actions that can be executed in the given state. The result would typically be a list, but if there are many actions, consider yielding them one at a time in an iterator, rather than building them all at once.

Parameters

  • _state: T

Returns never

goal_test

  • goal_test(state: T): boolean

Return True if the state is a goal. The default method compares the state to self.goal or checks for state in self.goal if it is a list, as specified in the constructor. Override this method if checking against a single self.goal is not enough.

Parameters

  • state: T

Returns boolean

path_cost

  • path_cost(c: number, _state1: T, _action: any, _state2: T): number

Return the cost of a solution path that arrives at state2 from state1 via action, assuming cost c to get up to state1. If the problem is such that the path doesn't matter, this function will only look at state2. If the path does matter, it will consider c and maybe state1 and action. The default method costs 1 for every step in the path.

Parameters

  • c: number
  • _state1: T
  • _action: any
  • _state2: T

Returns number

result

  • result(_state: T, _action: any): never

Return the state that results from executing the given action in the given state. The action must be one of self.actions(state).

Parameters

  • _state: T
  • _action: any

Returns never

value

  • value(_state: T): never

For optimization problems, each state has a value. Hill Climbing and related algorithms try to maximize this value.

Parameters

  • _state: T

Returns never

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.