-
Notifications
You must be signed in to change notification settings - Fork 21
/
variable.go
40 lines (32 loc) · 989 Bytes
/
variable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package solver
// Identifier values uniquely identify particular Variables within
// the input to a single call to Solve.
type Identifier string
func (id Identifier) String() string {
return string(id)
}
// IdentifierFromString returns an Identifier based on a provided
// string.
func IdentifierFromString(s string) Identifier {
return Identifier(s)
}
// Variable values are the basic unit of problems and solutions
// understood by this package.
type Variable interface {
// Identifier returns the Identifier that uniquely identifies
// this Variable among all other Variables in a given
// problem.
Identifier() Identifier
// Constraints returns the set of constraints that apply to
// this Variable.
Constraints() []Constraint
}
// zeroVariable is returned by VariableOf in error cases.
type zeroVariable struct{}
var _ Variable = zeroVariable{}
func (zeroVariable) Identifier() Identifier {
return ""
}
func (zeroVariable) Constraints() []Constraint {
return nil
}