Documentation
¶
Overview ¶
Package discrete contains the common parts to discrete optimization problems
Index ¶
- type BaseConstraint
- type Constraint
- type ConstraintFn
- type GlobalConstraint
- type Goal
- type ObjectiveFn
- type Penalty
- type Problem
- func (p *Problem) AddConstraint(constraint Constraint)
- func (p *Problem) AddGlobalConstraint(test ConstraintFn, penalty Penalty, variables ...Variable)
- func (p *Problem) AddUniversalConstraint(test ConstraintFn)
- func (p Problem) ComputeScore(solution *Solution)
- func (p Problem) IsOptimization() bool
- func (p Problem) IsSatisfaction() bool
- func (p Problem) IsSatisfied(solution *Solution) bool
- func (p Problem) SolutionSpace() int
- func (p Problem) SolutionSpaceEquation() string
- type ProblemType
- type Score
- type Solution
- type SolutionCoreFn
- type SolutionStringFn
- type Value
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseConstraint ¶
type BaseConstraint struct {
Penalty
Variables []Variable
Test ConstraintFn
}
The base Constraint type
func (BaseConstraint) ComputePenalty ¶
func (c BaseConstraint) ComputePenalty(solution *Solution) Penalty
Computes the penalty for the given solution
func (BaseConstraint) IsSatisfied ¶
func (c BaseConstraint) IsSatisfied(solution *Solution) bool
Checks if solution satisfies the constraint test
type Constraint ¶
type ConstraintFn ¶
type GlobalConstraint ¶
type GlobalConstraint struct {
BaseConstraint
}
Constraint with more than 2 variables
type ObjectiveFn ¶
type Problem ¶
type Problem struct {
Name string
Type ProblemType
Variables []Variable
Domain map[Variable][]Value
Constraints []Constraint
Goal
ObjectiveFn
SolutionCoreFn
SolutionStringFn
}
func (*Problem) AddConstraint ¶
func (p *Problem) AddConstraint(constraint Constraint)
Add new constraint to problem
func (*Problem) AddGlobalConstraint ¶
func (p *Problem) AddGlobalConstraint(test ConstraintFn, penalty Penalty, variables ...Variable)
Add Global constraint to problem, with given penalty and variables
func (*Problem) AddUniversalConstraint ¶
func (p *Problem) AddUniversalConstraint(test ConstraintFn)
Add Universal constraint to problem (all problem variables are involved)
func (Problem) ComputeScore ¶
Computes and attaches solution score by calling the ObjectiveFn
func (Problem) IsOptimization ¶
Check if optimization problem
func (Problem) IsSatisfaction ¶
Check if satisfaction problem
func (Problem) IsSatisfied ¶
Check if solution satisfies the problem constraints
func (Problem) SolutionSpace ¶
Compute the total solution space of the problem
func (Problem) SolutionSpaceEquation ¶
Create the solution space equation of the problem
type ProblemType ¶
type ProblemType string
const ( Assignment ProblemType = "assignment" Partition ProblemType = "partition" Sequence ProblemType = "sequence" Subset ProblemType = "subset" Path ProblemType = "path" )
type Solution ¶
func ZipSolution ¶
Create new solution by zipping variables, values
type SolutionCoreFn ¶
type SolutionStringFn ¶
type Value ¶
type Value = int
func IndexDomain ¶
Creates a list of values from [0, numItems)
func PathDomain ¶
Creates a list of values from [-1, 0, numItems)
func RangeDomain ¶
Creates a list of values from [first, last]
type Variable ¶
type Variable = int
func IndexVariables ¶
Create list of variables from [0, numItems)
func RangeVariables ¶
Create list of variables from [first, last]