Transforme la pénalité conditionnelle en un bonus de départage très petit
parent
ee1dcaf389
commit
94d54f6847
|
@ -25,6 +25,7 @@ export let makeJsx = node =>
|
|||
|
||||
export let collectNodeMissing = node => node.missingVariables || {}
|
||||
|
||||
export let bonus = (missings, hasCondition=true) => hasCondition ? map(x=>x+.0001, missings || {}) : missings
|
||||
export let mergeAllMissing = missings => reduce(mergeWith(add),{},map(collectNodeMissing,missings))
|
||||
export let mergeMissing = (left, right) => mergeWith(add, left || {}, right || {})
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ import {
|
|||
parseObject,
|
||||
collectNodeMissing,
|
||||
mergeAllMissing,
|
||||
mergeMissing
|
||||
mergeMissing,
|
||||
bonus
|
||||
} from './evaluation'
|
||||
import {
|
||||
findRuleByName,
|
||||
|
@ -160,8 +161,8 @@ let devariate = (recurse, k, v) => {
|
|||
: mergeAllMissing(pluck('condition', explanation)),
|
||||
rightMissing = choice === false
|
||||
? {}
|
||||
: map(x=>x-1, mergeAllMissing(satisfied)),
|
||||
missingVariables = mergeMissing(leftMissing, rightMissing)
|
||||
: mergeAllMissing(satisfied),
|
||||
missingVariables = mergeMissing(bonus(leftMissing), rightMissing)
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
@ -318,7 +319,7 @@ export let mecanismNumericalSwitch = (recurse, k, v) => {
|
|||
rightMissing = investigate
|
||||
? explanation.consequence.missingVariables
|
||||
: {},
|
||||
missingVariables = mergeMissing(leftMissing, rightMissing)
|
||||
missingVariables = mergeMissing(bonus(leftMissing), rightMissing)
|
||||
|
||||
return {
|
||||
...node,
|
||||
|
|
|
@ -60,7 +60,8 @@ import {
|
|||
rewriteNode,
|
||||
makeJsx,
|
||||
mergeMissing,
|
||||
mergeAllMissing
|
||||
mergeAllMissing,
|
||||
bonus
|
||||
} from './evaluation'
|
||||
import {
|
||||
anyNull,
|
||||
|
@ -492,7 +493,10 @@ export let treatRuleRoot = (rules, rule) => {
|
|||
),
|
||||
collectInFormule = isApplicable !== false,
|
||||
formMissing = (collectInFormule && formule.missingVariables) || {},
|
||||
missingVariables = mergeMissing(condMissing, formMissing)
|
||||
// On veut abaisser le score des conséquences par rapport aux conditions,
|
||||
// mais seulement dans le cas où une condition est effectivement présente
|
||||
hasCondition = keys(condMissing).length > 0,
|
||||
missingVariables = mergeMissing(bonus(condMissing,hasCondition), formMissing)
|
||||
|
||||
cache.parseLevel--
|
||||
// if (keys(condMissing).length) console.log("".padStart(cache.parseLevel-1),{conditions:condMissing, formule:formMissing})
|
||||
|
|
Loading…
Reference in New Issue