Documentation
¶
Index ¶
- Constants
- func GetDefinesVarAnnotation(variable string) string
- type Annotations
- type CPSolution
- type DataPathCSP
- type Declares
- type FlatZincConstraint
- type FlatZincModel
- func (fzw *FlatZincModel) AddConstraint(identifier string, exprs []string, annotations ...string)
- func (fzw *FlatZincModel) AddHeaderComment(commentLine string)
- func (fzw *FlatZincModel) AddParam(name, varType, assignment string)
- func (fzw *FlatZincModel) AddParamArray(name, varType string, size int, assignment string)
- func (fzw *FlatZincModel) AddVariable(name, varType string, isDefined, isOutput bool)
- func (fzw *FlatZincModel) AddVariableArray(name, varType string, size int, isDefined, isOutput bool)
- func (fzw *FlatZincModel) Clear()
- func (fzw *FlatZincModel) Dump() (string, error)
- func (fzw *FlatZincModel) GetVariableSize(name string) int
- func (fzw *FlatZincModel) GetVariableType(name string) string
- func (fzw *FlatZincModel) ReadBestSolution(solverOutput string) (CPSolution, error)
- func (fzw *FlatZincModel) ReadBestSolutionFromFile(fileName string) (CPSolution, error)
- func (fzw *FlatZincModel) ReadSolutions(solverOutput string) ([]CPSolution, error)
- func (fzw *FlatZincModel) ReadSolutionsFromFile(fileName string) ([]CPSolution, error)
- func (fzw *FlatZincModel) SetSolveTarget(goal SolveGoal, expr string, annotations ...string)
- func (fzw *FlatZincModel) SetVariableAssignment(name, assignment string)
- type FlatZincParam
- type FlatZincSolveItem
- type FlatZincVariable
- type Optimizer
- type SolveGoal
Constants ¶
const ( TrueValue = "true" FalseValue = "false" BoolType = "bool" IntType = "int" BoolLeConstraint = "bool_le" BoolLinEqConstraint = "bool_lin_eq" BoolLinLeConstraint = "bool_lin_le" BoolNotEqConstraint = "bool_not" ArrBoolOrConstraint = "array_bool_or" IntEqConstraint = "int_eq_reif" IntNotEqConstraint = "int_ne_reif" IntLeConstraint = "int_le_reif" SetInConstraint = "set_in_reif" IntLinEqConstraint = "int_lin_eq" ArrIntElemConstraint = "array_var_int_element" IntMaxConstraint = "array_int_maximum" DefinedVarAnnotation = "is_defined_var" DefinesVarAnnotation = "defines_var(%s)" OutputVarAnnotation = "output_var" OutputArrAnnotation = "output_array([1..%d])" ElementSeparator = ", " )
const (
MaxDataPathDepth = 4
)
Variables ¶
This section is empty.
Functions ¶
func GetDefinesVarAnnotation ¶
Types ¶
type Annotations ¶
type Annotations []string
type CPSolution ¶
Represents a solution to the constraints problem - a map from variable names to their value(s) in the solution
type DataPathCSP ¶
type DataPathCSP struct {
// contains filtered or unexported fields
}
The main class for producing a CSP from data-path constraints and for decoding solver's solutions
func NewDataPathCSP ¶
func NewDataPathCSP(problemData *datapath.DataInfo, env *datapath.Environment) *DataPathCSP
The ctor also enumerates all available (module x capabilities) and all available interfaces The generated enumerations are listed at the header of the FlatZinc model
func (*DataPathCSP) BuildFzModel ¶
func (dpc *DataPathCSP) BuildFzModel(pathLength int) (string, error)
This is the main method for building a FlatZinc CSP out of the data-path parameters and constraints. Returns a file name where the model was dumped
NOTE: Minimal index of FlatZinc arrays is always 1. Hence, we use 1-based modeling all over the place to avoid confusion. The only exception is with interfaces (0 means nil)
type FlatZincConstraint ¶
type FlatZincConstraint struct { Identifier string Expressions []string Annotations }
Data for a single FlatZinc constraint
type FlatZincModel ¶
type FlatZincModel struct { HeaderComments string ParamMap map[string]Declares VarMap map[string]Declares Constraints []FlatZincConstraint SolveTarget FlatZincSolveItem }
The main class for holding a FlatZinc constraint problem
func NewFlatZincModel ¶
func NewFlatZincModel() *FlatZincModel
func (*FlatZincModel) AddConstraint ¶
func (fzw *FlatZincModel) AddConstraint(identifier string, exprs []string, annotations ...string)
func (*FlatZincModel) AddHeaderComment ¶
func (fzw *FlatZincModel) AddHeaderComment(commentLine string)
func (*FlatZincModel) AddParam ¶
func (fzw *FlatZincModel) AddParam(name, varType, assignment string)
func (*FlatZincModel) AddParamArray ¶
func (fzw *FlatZincModel) AddParamArray(name, varType string, size int, assignment string)
func (*FlatZincModel) AddVariable ¶
func (fzw *FlatZincModel) AddVariable(name, varType string, isDefined, isOutput bool)
func (*FlatZincModel) AddVariableArray ¶
func (fzw *FlatZincModel) AddVariableArray(name, varType string, size int, isDefined, isOutput bool)
func (*FlatZincModel) Clear ¶
func (fzw *FlatZincModel) Clear()
func (*FlatZincModel) Dump ¶
func (fzw *FlatZincModel) Dump() (string, error)
dumps a FlatZinc model to a temp file using the FlatZinc syntax, returning the file name It is the caller responsibility to delete the file
func (*FlatZincModel) GetVariableSize ¶ added in v1.0.0
func (fzw *FlatZincModel) GetVariableSize(name string) int
func (*FlatZincModel) GetVariableType ¶ added in v1.0.0
func (fzw *FlatZincModel) GetVariableType(name string) string
func (*FlatZincModel) ReadBestSolution ¶
func (fzw *FlatZincModel) ReadBestSolution(solverOutput string) (CPSolution, error)
Reading FlatZinc-solver solutions and returning the best one When a minimize/maximize goal is defined, best solution should be the last solution
func (*FlatZincModel) ReadBestSolutionFromFile ¶
func (fzw *FlatZincModel) ReadBestSolutionFromFile(fileName string) (CPSolution, error)
Just like ReadBestSolution() but reading the solutions from a file
func (*FlatZincModel) ReadSolutions ¶
func (fzw *FlatZincModel) ReadSolutions(solverOutput string) ([]CPSolution, error)
Reading FlatZinc-solver solutions and returning them as a slice of CPSolution If there can be no solution to the constraint problem (UNSAT), returns a slice with a single empty solution Otherwise, must return at least one solution, or return an error
func (*FlatZincModel) ReadSolutionsFromFile ¶
func (fzw *FlatZincModel) ReadSolutionsFromFile(fileName string) ([]CPSolution, error)
Just like ReadSolutions() but reading the solutions from a file
func (*FlatZincModel) SetSolveTarget ¶
func (fzw *FlatZincModel) SetSolveTarget(goal SolveGoal, expr string, annotations ...string)
func (*FlatZincModel) SetVariableAssignment ¶ added in v1.0.0
func (fzw *FlatZincModel) SetVariableAssignment(name, assignment string)
type FlatZincParam ¶
type FlatZincParam struct { Name string Type string Size int IsArray bool // (IsArray == false) implies (Size == 1) Assignment string }
Data for a single FlatZinc parameter
func (*FlatZincParam) Declaration ¶
func (fzp *FlatZincParam) Declaration() string
formats a parameter declaration in FlatZinc format
func (*FlatZincParam) GetSize ¶ added in v1.0.0
func (fzp *FlatZincParam) GetSize() int
func (*FlatZincParam) GetType ¶ added in v1.0.0
func (fzp *FlatZincParam) GetType() string
func (*FlatZincParam) SetAssignment ¶ added in v1.0.0
func (fzp *FlatZincParam) SetAssignment(assignment string)
type FlatZincSolveItem ¶
type FlatZincSolveItem struct { Annotations // contains filtered or unexported fields }
Data for a FlatZinc-model solve item
type FlatZincVariable ¶
type FlatZincVariable struct { Name string Type string Size int IsArray bool // (IsArray == false) implies (Size == 1) Assignment string Annotations }
Data for a single FlatZinc variable
func (*FlatZincVariable) Declaration ¶
func (fzv *FlatZincVariable) Declaration() string
formats a variable declaration in FlatZinc format
func (*FlatZincVariable) GetSize ¶ added in v1.0.0
func (fzv *FlatZincVariable) GetSize() int
func (*FlatZincVariable) GetType ¶ added in v1.0.0
func (fzv *FlatZincVariable) GetType() string
func (*FlatZincVariable) SetAssignment ¶ added in v1.0.0
func (fzv *FlatZincVariable) SetAssignment(assignment string)
type Optimizer ¶
type Optimizer struct {
// contains filtered or unexported fields
}