expert

package
v0.0.0-...-c0f9bd9 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2014 License: GPL-3.0 Imports: 1 Imported by: 0

README

expert

Expert system library

Installation
go get github.com/graarh/golang/expert
Usage

Complete examples will be available later.

Look for rule_test.go and expert_test.go for usage examples

Quick schema
1. Input parameters
   - request parameters <map[string]Parameter> <type Parameter interface{}>
   - request initial weight <Weight> <type Weight interface{}>
   - rule set <[]Rule>
2. Output result
   - weight <Weight>, ruleName <string>
3. Construction elements
   - <Rule: []conditions, []modifiers>
   - <condition.Check(params) bool>
   - <modifier.apply(Weight, params) Weight>

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 Modifier

type Modifier interface {
	Modify(weight data.Weight, params data.Parameters) data.Weight
}

Modifier interface modifies weight using initial weight and 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

type RuleRecord struct {
	RuleName       string
	RuleConditions []Condition
	RuleModifiers  []Modifier
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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