master > master: codego - cleanup

This commit is contained in:
RD
2021-05-14 18:35:06 +02:00
parent 89c8e63f4b
commit 39be87d52f
5 changed files with 57 additions and 42 deletions

View File

@@ -9,27 +9,27 @@ import (
* METHOD: Evaluation of fomulae in models
* ---------------------------------------------------------------- */
func Eval(tree formulae.Formula, I []string) int {
func Eval(fml formulae.Formula, I []string) int {
// Definiere (parameterisiertes) Schema:
var schema = func(_I []string) func(formulae.Formula, []int) int {
return func(tree formulae.Formula, prevValues []int) int {
if tree.IsAtom() || tree.IsGeneric() {
return utils.BoolToInt(utils.StrListContains(_I, tree.GetExpr()))
} else if tree.IsTautologySymbol() {
return func(fml formulae.Formula, prevValues []int) int {
if fml.IsAtom() || fml.IsGeneric() {
return utils.BoolToInt(utils.StrListContains(_I, fml.GetExpr()))
} else if fml.IsTautologySymbol() {
return 1
} else if tree.IsContradictionSymbol() {
} else if fml.IsContradictionSymbol() {
return 0
} else if tree.IsNegation() {
} else if fml.IsNegation() {
return 1 - prevValues[0]
} else if tree.IsConjunction2() {
} else if fml.IsConjunction2() {
return utils.Min2(prevValues[0], prevValues[1])
} else if tree.IsConjunction() {
} else if fml.IsConjunction() {
return utils.MinList(prevValues)
} else if tree.IsDisjunction2() {
} else if fml.IsDisjunction2() {
return utils.Max2(prevValues[0], prevValues[1])
} else if tree.IsDisjunction() {
} else if fml.IsDisjunction() {
return utils.MaxList(prevValues)
} else if tree.IsImplication() {
} else if fml.IsImplication() {
return utils.BoolToInt(prevValues[0] <= prevValues[1])
} else {
panic("Could not evaluate expression!")
@@ -38,5 +38,5 @@ func Eval(tree formulae.Formula, I []string) int {
}
// Erzeuge Funktion aus Schema und berechne Wert:
fn := formulae.CreateFromSchemeIntValued(schema(I))
return fn(tree)
return fn(fml)
}