ast

package
v0.0.0-...-9b02bcc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

Argument represents a statement argument (see Statement).

Argument = AssignmentsArgument
         | BinaryOpArgument
         | ConstantsArgument
         | CumulativeArgument
         | DomainArgument
         | ElementArgument
         | ImplicationArgument
         | IntervalsArgument
         | KArgument
         | LinearEqualityArgument
         | LinearExprsArgument
         | NonOverlapping2DArgument
         | VariableEqualityArgument
         | VariablesArgument .

type AssignmentsArgument

type AssignmentsArgument struct {
	Variables []string
	In        bool

	AllowedLiteralAssignments [][]bool // either-or
	AllowedIntVarAssignments  [][]int
}

AssignmentsArgument represents an assignment argument: [a,b] ∉ [0,0] ∪ [1,1]. It's used to test New{Allowed,Forbidden}{,Literal}AssignmentsConstraint.

AssignmentsArgument = "[" Variables "]" ( "∈" | "∉" ) ( NumbersList | BooleanList ) .

func (*AssignmentsArgument) AsInt64s

func (a *AssignmentsArgument) AsInt64s() [][]int64

AsInt64s converts the underlying assignments int matrix to a matrix of int64s.

func (*AssignmentsArgument) ForIntVars

func (a *AssignmentsArgument) ForIntVars() bool

ForIntVars returns true iff this argument refers to int vars.

func (*AssignmentsArgument) ForLiterals

func (a *AssignmentsArgument) ForLiterals() bool

ForLiterals returns true iff this argument refers to literals.

func (*AssignmentsArgument) String

func (a *AssignmentsArgument) String() string

type BinaryOpArgument

type BinaryOpArgument struct {
	Left, Right, Op, Target string
}

BinaryOpArgument represents a binary operation argument: a * b == c. It's used to test New{Product,Division,Modulo}Constraint.

BinaryOpArgument = Identifier ( "/" | "%" | "*" ) Identifier "==" Identifier .

func (*BinaryOpArgument) String

func (b *BinaryOpArgument) String() string

type ConstantsArgument

type ConstantsArgument struct {
	Variables []string
	Constant  int
}

ConstantsArgument represents a constants argument: a, b to c == 42. It's used to test NewConstant.

ConstantsArgument = Variables "==" Number .

func (*ConstantsArgument) String

func (c *ConstantsArgument) String() string

type CumulativeArgument

type CumulativeArgument struct {
	IntervalDemands []*IntervalDemand
	Capacity        string
}

CumulativeArgument represents a cumulative argument: i:2, j:4 | C. It's used to test NewCumulativeConstraint.

CumulativeArgument = IntervalDemands "|" Identifier .

func (*CumulativeArgument) Demands

func (c *CumulativeArgument) Demands() []string

Demands is a helper method that returns a slice of the underlying demands.

func (*CumulativeArgument) Intervals

func (c *CumulativeArgument) Intervals() []string

Intervals is a helper method that returns a slice of the underlying interval names.

func (*CumulativeArgument) String

func (c *CumulativeArgument) String() string

type Domain

type Domain struct {
	LowerBound, UpperBound int
}

Domain represents a unit domain.

Domain         = "[" Number "," Number "]" .

func (*Domain) String

func (d *Domain) String() string

type DomainArgument

type DomainArgument struct {
	Variables   []string // either-or
	LinearExprs []*LinearExpr

	Domains []*Domain
}

DomainArgument represents a domain argument: a, b to d in [0, 2]. It's used to test New{IntVar,LinearExpr}.

DomainArgument = ( Variables | LinearExprsMethod ) "in" Domains .

func (*DomainArgument) AsSolverDomain

func (d *DomainArgument) AsSolverDomain() solver.Domain

func (*DomainArgument) String

func (d *DomainArgument) String() string

type ElementArgument

type ElementArgument struct {
	Target, Index string
	Variables     []string
}

ElementArgument represents an element argument: t == [a,b,c][i]. It's used to test NewElementConstraint.

ElementArgument = Identifier "==" "[" Variables "]" "[" Identifier "]" .

func (*ElementArgument) String

func (e *ElementArgument) String() string

type Enforcement

type Enforcement struct {
	Literals []string
}

Enforcement represents the enforcement clause (see Statement).

Enforcement = "if" Variables .

func (*Enforcement) String

func (e *Enforcement) String() string

type ImplicationArgument

type ImplicationArgument struct {
	Left, Right string
}

ImplicationArgument represents an implication argument: a → b. It's used to test NewImplicationConstraint.

ImplicationArgument = Identifier "→" Identifier .

func (*ImplicationArgument) String

func (i *ImplicationArgument) String() string

type Interval

type Interval struct {
	Name, Start, End, Size string // variables
}

Interval represents a single interval.

Interval       = Identifier "as" "[" Identifier "," Identifier "|" Identifier "]" .

func (*Interval) String

func (i *Interval) String() string

type IntervalDemand

type IntervalDemand struct {
	Name   string
	Demand string
}

IntervalDemand represents an interval identifier and it's corresponding demand.

IntervalDemand = Identifier ":" Identifier .

func (*IntervalDemand) String

func (i *IntervalDemand) String() string

type IntervalsArgument

type IntervalsArgument struct {
	Intervals []*Interval
}

IntervalsArgument represents an intervals argument: i as [s, e| sz] It's used to test NewInterval.

IntervalsArgument = Intervals .

func (*IntervalsArgument) String

func (i *IntervalsArgument) String() string

type KArgument

type KArgument struct {
	Literals []string
	K        int
}

KArgument represents a k-argument: a, b to f | 4. It's used to test New{AtLeast,AtMost,Exactly}KConstraint.

KArgument = Variables "|" Digits .

func (*KArgument) String

func (k *KArgument) String() string

type LinearEqualityArgument

type LinearEqualityArgument struct {
	Target *LinearExpr
	Exprs  []*LinearExpr
	Op     string
}

LinearEqualityArgument represents a linear expression equality argument: 2j == max(k+i, i+2f). It's used to test NewLinear{Maximum,Minimum}Constraint

LinearEqualityArgument   = LinearExpr "==" ( "max" | "min" ) "(" LinearExprsMethod ")" .

func (*LinearEqualityArgument) String

func (l *LinearEqualityArgument) String() string

type LinearExpr

type LinearExpr struct {
	LinearTerms []*LinearTerm
}

LinearExpr represents a linear expression.

LinearExpr     = [ "-" ] LinearTerm { ( "+" | "-" ) LinearTerm } | "Σ" "(" Variables ")" .

func (*LinearExpr) String

func (l *LinearExpr) String() string

type LinearExprsArgument

type LinearExprsArgument struct {
	Exprs []*LinearExpr
}

LinearExprsArgument represents an argument comprised of linear expressions.

LinearExprsArgument = LinearExprsMethod .

func (*LinearExprsArgument) String

func (l *LinearExprsArgument) String() string

type LinearTerm

type LinearTerm struct {
	Coefficient int
	Variable    string
}

LinearTerm represents an individual term in a linear expression (see LinearExpr). If the embedded variable is the empty string, the term is a just a constant.

LinearTerm     = { Digits } Identifier | Digits .

func (*LinearTerm) String

func (l *LinearTerm) String() string

type Method

type Method int
const (
	Unrecognized Method = 0

	AllDifferentMethod Method = iota + 128
	AllSameMethod
	AssignmentsMethod
	AtLeastKMethod
	AtMostKMethod
	BinaryOpMethod
	BooleanAndMethod
	BooleanOrMethod
	BooleanXorMethod
	BoolsMethod
	ConstantsMethod
	CumulativeMethod
	ElementMethod
	EqualityMethod
	ExactlyKMethod
	ImplicationMethod
	IntervalsMethod
	LinearExprsMethod
	LiteralsMethod
	MaximizeMethod
	MinimizeMethod
	NameMethod
	NonOverlappingMethod
	NonOverlapping2DMethod
	ObjectiveValueMethod
	PrintMethod
	SolveMethod
	SolveAllMethod
	ValidateMethod
	ValuesMethod
	VarsMethod
)

func LookupMethod

func LookupMethod(s string) (Method, bool)

func (Method) String

func (m Method) String() string

type NonOverlapping2DArgument

type NonOverlapping2DArgument struct {
	XVariables, YVariables    []string
	BoxesWithNoAreaCanOverlap bool
}

NonOverlapping2DArgument represents an argument x and y interval variables, and a boolean indicating whether or not zero area boxes can overlap: [i, j], [k, l], false. It's used to test NewNonOverlapping2DConstraint.

NonOverlapping2DArgument = "[" Variables "]" "," "[" Variables "]" "," Boolean .

func (*NonOverlapping2DArgument) String

func (n *NonOverlapping2DArgument) String() string

type Statement

type Statement struct {
	Receiver    string
	Method      Method
	Argument    Argument
	Enforcement *Enforcement
}

Statement represents a single statement.

Statement   = Receiver "." Method "(" [ Argument ] ")" [ Enforcement ] .

func (*Statement) String

func (s *Statement) String() string

type VariableEqualityArgument

type VariableEqualityArgument struct {
	Target    string
	Variables []string
	Op        string
}

VariableEqualityArgument represents a variable equality argument: j == min(k, i, f). It's used to test New{Minimum,Maximum}Constraint.

VariableEqualityArgument = Identifier "==" ( "max" | "min" ) "(" Variables ")" .

func (*VariableEqualityArgument) String

func (v *VariableEqualityArgument) String() string

type VariablesArgument

type VariablesArgument struct {
	Variables []string
}

VariablesArgument represents an argument comprised of variables.

VariablesArgument        = Variables .

func (*VariablesArgument) AsLinearExprsArgument

func (v *VariablesArgument) AsLinearExprsArgument() *LinearExprsArgument

AsLinearExprsArgument returns a LinearExprsArgument representation of the VariablesArgument.

func (*VariablesArgument) String

func (v *VariablesArgument) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL