Guest User

CSP Types

a guest
Dec 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.09 KB | None | 0 0
  1. type
  2.     Variable[T] = ref object
  3.         ## Represents a Node in the CSP Graph
  4.         name: string
  5.             ## Unique name of the Variable
  6.             ## TODO: Currently user-enforced
  7.         domain: seq[T]
  8.             ## Domain of the variable as a
  9.             ## finite, ordered set
  10.         value: T
  11.             ## Current value of the variable,
  12.             ## used to represent an assignment
  13.    
  14.     Constraint*[T] = ref object
  15.         ## A function that subsets valid combinations
  16.         ## of values for its variables. Represents
  17.         ## an Arc or Multi-Arc in the CSP Graph
  18.         variables: seq[Variable[T]]
  19.             ## The list of Variable objects checked
  20.         predicate: proc(x: varargs[T]): bool
  21.             ## The function computing satisfaction
  22.  
  23.     Problem*[T] = ref object
  24.         ## A CSP Graph with well-defined solving algorithms
  25.         variables: TableRef[string, Variable[T]]
  26.             ## Links the Names of Nodes to their Reference
  27.         constraints: TableRef[string, seq[Constraint[T]]]
  28.             ## Links the Names of Nodes to their Constraints
Advertisement
Add Comment
Please, Sign In to add comment