Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calculator ¶
type Calculator struct {
Rules []Rule
}
Calculator structure initializes calculator
func (*Calculator) Max ¶
func (c *Calculator) Max(initial data.Weight, params data.Parameters) (data.Weight, string)
Optimal finds maximum weight
func (*Calculator) Sum ¶
func (c *Calculator) Sum(initial data.Weight, params data.Parameters) []string
Collect collects weights to initial
type Condition ¶
type Condition interface {
Check(params data.Parameters) bool
}
Condition is the interface that defines one single check using input parameters
type Rule ¶
type Rule interface { Name() string Conditions() []Condition Modifiers() []Modifier Calculate(initial data.Weight, params data.Parameters) (data.Weight, bool) }
Rule is the interface of expert system that should affect weight then params pass conditions
type RuleRecord ¶
RuleRecord is the base implementation of the Rule interface
func (*RuleRecord) Calculate ¶
func (p *RuleRecord) Calculate(initial data.Weight, params data.Parameters) (data.Weight, bool)
Calculate applies modifiers to initial weight if conditions are passed with given params, implementation of the Rule interface
func (*RuleRecord) Conditions ¶
func (p *RuleRecord) Conditions() []Condition
Conditions is the Rule interface implementation
func (*RuleRecord) Modifiers ¶
func (p *RuleRecord) Modifiers() []Modifier
Modifiers is the Rule interface implementation
func (*RuleRecord) Name ¶
func (p *RuleRecord) Name() string
Name is the Rule interface implementation
Click to show internal directories.
Click to hide internal directories.