Replies: 2 comments 1 reply
-
Opened Issue #419. |
Beta Was this translation helpful? Give feedback.
-
There is a simple (but not very elegant) solution: add a Forget() function after every statement that is repeated in the rule set (in your case MF.GetMult(2);) Working example:
Result: 16000 This is due to overly aggressive use of caching, not only for all variables, but also for all expressions. An elegant option would be to be able to indicate that I don't want to cache the output of the expression when calling it - for example, I would like to be able to put an exclamation mark (or any other special character like 🗑 :) ) after the expression to indicate that I don't want to cache this expression (e.g. MF.N = MF.GetMult(2)!;). The implementation would probably not be complicated, but I don't dare to interfere with the AST parsing and processing. |
Beta Was this translation helpful? Give feedback.
-
Dear team,
I'm having a look to this rule engine, and I write the below code and as you could see three rules call this function: MF.N = MF.GetMult(x);.
GetMult just multiplies the MF.N by the parameter (x).
The issue: If the three has the same number in this case 2 I got as result 4.000, instead of 8 / 16.000. if I put different numbers such MF.GetMult(3); MF.GetMult(5); and MF.GetMult(2); I got a multiplier of 30 which turns in the correct answer 60.000.
What am I doing wrongly?
Regards
Antonio
package main
import (
"fmt"
)
type MyFact struct {
A string
B string
C string
D string
M float64
N float64
}
func main() {
kb := ast.NewKnowledgeLibrary()
rb := builder.NewRuleBuilder(kb)
}
func (mf *MyFact) GetMult(factor int64) float64 {
}
Beta Was this translation helpful? Give feedback.
All reactions