model

package
v0.0.0-...-4dcd76e Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const WeightsParam = "weights"

Variables

This section is empty.

Functions

func AddCriterionToAlternatives

func AddCriterionToAlternatives(
	alternatives *[]AlternativeWithCriteria,
	newCriterion *Criterion,
	valueProvider func(alt *AlternativeWithCriteria) Weight,
) *[]AlternativeWithCriteria

func CopyAlternatives

func CopyAlternatives(alternatives *[]AlternativeWithCriteria) *[]AlternativeWithCriteria

func CriteriaValuesRange

func CriteriaValuesRange(alternatives *[]AlternativeWithCriteria, criterion *Criterion) *utils.ValueRange

func FetchAlternatives

func FetchAlternatives(a *[]AlternativeWithCriteria, ids *[]Alternative) *[]AlternativeWithCriteria

func GetNormalScaleRatio

func GetNormalScaleRatio(currentRange *utils.ValueRange) float64

func GetScaleRatio

func GetScaleRatio(target *utils.ValueRange, currentRange *utils.ValueRange) float64

func IsStringBlank

func IsStringBlank(str *string) bool

func PreserveCriteriaForAlternatives

func PreserveCriteriaForAlternatives(alternatives *[]AlternativeWithCriteria, criteria *Criteria) *[]AlternativeWithCriteria

func ShuffleAlternatives

func ShuffleAlternatives(alternatives *[]AlternativeWithCriteria, generator utils.ValueGenerator) *[]AlternativeWithCriteria

func SortAlternativesByName

func SortAlternativesByName(alternatives *[]AlternativeWithCriteria) *[]AlternativeWithCriteria

func ValuesRangeWithGroundZero

func ValuesRangeWithGroundZero(alternatives *[]AlternativeWithCriteria, criterion *Criterion) *utils.ValueRange

func WeightsParamOnly

func WeightsParamOnly() interface{}

Types

type AddedCriterionParams

type AddedCriterionParams = MethodParameters

type Alternative

type Alternative = string

type AlternativeResult

type AlternativeResult struct {
	Alternative AlternativeWithCriteria `json:"alternative"`
	Evaluation  interface{}             `json:"evaluation"`
}

func ValueAlternativeResult

func ValueAlternativeResult(alternative *AlternativeWithCriteria, value float64) *AlternativeResult

func (*AlternativeResult) Identifier

func (a *AlternativeResult) Identifier() string

func (*AlternativeResult) String

func (a *AlternativeResult) String() string

func (*AlternativeResult) Value

func (a *AlternativeResult) Value() float64

type AlternativeResults

type AlternativeResults []AlternativeResult

func (*AlternativeResults) Len

func (a *AlternativeResults) Len() int

func (*AlternativeResults) Less

func (a *AlternativeResults) Less(i, j int) bool

func (*AlternativeResults) Ranking

func (*AlternativeResults) Swap

func (a *AlternativeResults) Swap(i, j int)

type AlternativeWeightFunction

type AlternativeWeightFunction func(alternative *AlternativeWithCriteria) *AlternativeResult

type AlternativeWithCriteria

type AlternativeWithCriteria struct {
	Id       Alternative `json:"id"`
	Criteria Weights     `json:"criteria"`
}

func RemoveAlternative

func RemoveAlternative(alternatives []AlternativeWithCriteria, alternative AlternativeWithCriteria) []AlternativeWithCriteria

func RemoveAlternativeAt

func RemoveAlternativeAt(alternatives []AlternativeWithCriteria, index int) []AlternativeWithCriteria

func (*AlternativeWithCriteria) CriterionRawValue

func (a *AlternativeWithCriteria) CriterionRawValue(criterion *Criterion) Weight

func (*AlternativeWithCriteria) CriterionValue

func (a *AlternativeWithCriteria) CriterionValue(criterion *Criterion) Weight

func (*AlternativeWithCriteria) String

func (a *AlternativeWithCriteria) String() string

func (*AlternativeWithCriteria) WithCriteriaOnly

func (a *AlternativeWithCriteria) WithCriteriaOnly(criteria *Criteria) *AlternativeWithCriteria

func (*AlternativeWithCriteria) WithCriteriaValues

func (a *AlternativeWithCriteria) WithCriteriaValues(criteriaValues *Weights) *AlternativeWithCriteria

func (*AlternativeWithCriteria) WithCriterion

func (a *AlternativeWithCriteria) WithCriterion(name string, value Weight) *AlternativeWithCriteria

type Alternatives

type Alternatives []Alternative

type AlternativesRankEntry

type AlternativesRankEntry struct {
	AlternativeResult
	BetterThanOrSameAs Alternatives `json:"betterThanOrSameAs"` // preference >=
}

type AlternativesRanking

type AlternativesRanking []AlternativesRankEntry

func (*AlternativesRanking) ReverseOrder

func (r *AlternativesRanking) ReverseOrder()

type Bias

type Bias interface {
	utils.Identifiable
	Apply(
		original, current *DecisionMakingParams,
		props *BiasProps,
		listener *BiasListener,
	) *BiasedResult
}

type BiasListeners

type BiasListeners struct {
	Listeners []BiasListener
}

func (*BiasListeners) Fetch

func (pf *BiasListeners) Fetch(listenerName string) *BiasListener

func (*BiasListeners) Get

func (pf *BiasListeners) Get(index int) utils.Identifiable

func (*BiasListeners) Len

func (pf *BiasListeners) Len() int

type BiasMap

type BiasMap = map[string]Bias

func AsBiasesMap

func AsBiasesMap(h *Biases) *BiasMap

type BiasParams

type BiasParams struct {
	Name             string    `json:"name"`
	Disabled         bool      `json:"disabled"`
	ApplyProbability float64   `json:"applyProbability"`
	Props            BiasProps `json:"props"`
}

func UpdateBiasesProps

func UpdateBiasesProps(oldProps *BiasParams, update BiasProps) *BiasParams

type BiasProps

type BiasProps = interface{}

type BiasWithProps

type BiasWithProps struct {
	Bias  *Bias       `json:"bias"`
	Props *BiasParams `json:"props"`
}

type BiasedResult

type BiasedResult struct {
	DMP   *DecisionMakingParams `json:"dm"`
	Props BiasProps             `json:"props"`
}

type Biases

type Biases = []Bias

type BiasesParams

type BiasesParams = []interface{}

type BiasesWithProps

type BiasesWithProps = []BiasWithProps

func ChooseBiases

func ChooseBiases(available *BiasMap, choose *BiasesParams) *BiasesWithProps

type Criteria

type Criteria []Criterion

func (*Criteria) Add

func (c *Criteria) Add(criterion *Criterion) Criteria

func (*Criteria) FindWeight

func (c *Criteria) FindWeight(weights *Weights, criterion *Criterion) Weight

func (*Criteria) First

func (c *Criteria) First() Criterion

func (*Criteria) Get

func (c *Criteria) Get(index int) utils.Identifiable

func (*Criteria) Len

func (c *Criteria) Len() int

func (*Criteria) Names

func (c *Criteria) Names() *[]string

func (*Criteria) NotUsedName

func (c *Criteria) NotUsedName(name string) string

func (*Criteria) ShallowCopy

func (c *Criteria) ShallowCopy() *Criteria

func (*Criteria) SortByWeights

func (c *Criteria) SortByWeights(weights Weights) *WeightedCriteria

func (*Criteria) Validate

func (c *Criteria) Validate()

func (*Criteria) Weight

func (c *Criteria) Weight(weights Weights, criterionIndex int) Weight

func (*Criteria) ZipWithWeights

func (c *Criteria) ZipWithWeights(weights *Weights) *WeightedCriteria

type CriteriaRanker

type CriteriaRanker interface {
	RankCriteriaAscending(params *DecisionMakingParams) *WeightedCriteria
}

type Criterion

type Criterion struct {
	Id          string            `json:"id"`
	Type        CriterionType     `json:"type"`
	ValuesRange *utils.ValueRange `json:"valuesRange,omitempty"`
}

func (Criterion) Identifier

func (c Criterion) Identifier() string

func (*Criterion) IsGain

func (c *Criterion) IsGain() bool

func (*Criterion) Multiplier

func (c *Criterion) Multiplier() int8

type CriterionAdder

type CriterionAdder interface {
	OnCriterionAdded(
		criterion *Criterion,
		referenceCriterion *Criterion,
		params MethodParameters,
		generator utils.ValueGenerator,
	) AddedCriterionParams
}

type CriterionRemover

type CriterionRemover interface {
	OnCriteriaRemoved(leftCriteria *Criteria, params MethodParameters) MethodParameters
}

type CriterionType

type CriterionType string
const (
	Gain CriterionType = "gain"
	Cost CriterionType = "cost"
)

type DecisionMaker

type DecisionMaker struct {
	PreferenceFunction  string                    `json:"preferenceFunction"`
	Biases              BiasesParams              `json:"biases"`
	BiasApplyRandomSeed int64                     `json:"biasApplyRandomSeed"`
	KnownAlternatives   []AlternativeWithCriteria `json:"knownAlternatives"`
	ChoseToMake         []Alternative             `json:"choseToMake"`
	Criteria            Criteria                  `json:"criteria"`
	MethodParameters    RawMethodParameters       `json:"methodParameters"`
}

func (*DecisionMaker) Alternative

func (*DecisionMaker) AlternativesToConsider

func (dm *DecisionMaker) AlternativesToConsider() *[]AlternativeWithCriteria

func (*DecisionMaker) MakeDecision

func (dm *DecisionMaker) MakeDecision(
	preferenceFunctions PreferenceFunctions,
	biasListeners BiasListeners,
	availableBiases *BiasMap,
	biasApplyProbGenerator utils.SeededValueGenerator,
) *DecisionMakerChoice

func (*DecisionMaker) NotConsideredAlternatives

func (dm *DecisionMaker) NotConsideredAlternatives() *[]AlternativeWithCriteria

type DecisionMakerChoice

type DecisionMakerChoice struct {
	Result AlternativesRanking `json:"result"`
	Biases BiasesParams        `json:"biases"`
}

type DecisionMakingParams

type DecisionMakingParams struct {
	NotConsideredAlternatives []AlternativeWithCriteria
	ConsideredAlternatives    []AlternativeWithCriteria
	Criteria                  Criteria
	MethodParameters          interface{}
}

func (*DecisionMakingParams) AllAlternatives

func (p *DecisionMakingParams) AllAlternatives() []AlternativeWithCriteria

type EvaluationSingleValue

type EvaluationSingleValue struct {
	Value float64 `json:"value"`
}

type MethodParameters

type MethodParameters = interface{}

type MethodParametersMerger

type MethodParametersMerger interface {
	Merge(params MethodParameters, addition MethodParameters) MethodParameters
}

type PreferenceFunction

type PreferenceFunction interface {
	utils.Identifiable
	MethodParameters() interface{}
	ParseParams(dm *DecisionMaker) interface{}
	Evaluate(dmp *DecisionMakingParams) *AlternativesRanking
}

type PreferenceFunctions

type PreferenceFunctions struct {
	Functions []PreferenceFunction `json:"functions"`
}

func (*PreferenceFunctions) Fetch

func (pf *PreferenceFunctions) Fetch(function string) *PreferenceFunction

func (*PreferenceFunctions) FetchParameters

func (pf *PreferenceFunctions) FetchParameters() *map[string]interface{}

func (*PreferenceFunctions) Get

func (pf *PreferenceFunctions) Get(index int) utils.Identifiable

func (*PreferenceFunctions) Len

func (pf *PreferenceFunctions) Len() int

type RawMethodParameters

type RawMethodParameters = map[string]interface{}

type Weight

type Weight = float64

func NewCriterionValue

func NewCriterionValue(previousWeights *Weights, baseCriterion *Criterion, generator *utils.ValueGenerator) Weight

func WeightIdentity

func WeightIdentity(criterion string, value Weight) Weight

type WeightType

type WeightType struct {
	Weights Weights `json:"weights"`
}

func SingleWeight

func SingleWeight(criterion *Criterion, value Weight) WeightType

type WeightedCriteria

type WeightedCriteria []WeightedCriterion

func (*WeightedCriteria) Criteria

func (w *WeightedCriteria) Criteria() *Criteria

type WeightedCriterion

type WeightedCriterion struct {
	Criterion
	Weight Weight `json:"weight"`
}

func (*WeightedCriterion) AsWeights

func (c *WeightedCriterion) AsWeights() *Weights

type Weights

type Weights map[string]Weight

func ExtractWeights

func ExtractWeights(dm *DecisionMaker) Weights

func PrepareCumulatedWeightsMap

func PrepareCumulatedWeightsMap(
	params *DecisionMakingParams,
	mapper func(criterion string, value Weight) Weight,
) *Weights

func RescaleCriterion

func RescaleCriterion(c *Criterion, alternatives *[]AlternativeWithCriteria, target *utils.ValueRange) Weights

func (*Weights) AsKeyValue

func (w *Weights) AsKeyValue() []namedWeight

func (*Weights) Copy

func (w *Weights) Copy() *Weights

func (*Weights) Fetch

func (w *Weights) Fetch(key string) Weight

func (*Weights) Merge

func (w *Weights) Merge(other *Weights) *Weights

func (*Weights) PreserveOnly

func (w *Weights) PreserveOnly(criteria *Criteria) *Weights

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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