Move selection logic to chooseCalculationMethod
This commit is contained in:
parent
65397b3fe0
commit
898750f8f9
|
@ -191,10 +191,23 @@ module AlgebraicCombination = {
|
||||||
| _ => 1000
|
| _ => 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
let chooseConvolutionOrMonteCarlo = (t2: t, t1: t) =>
|
type calculationMethod = MonteCarlo | Convolution(Operation.convolutionOperation)
|
||||||
expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > 10000
|
|
||||||
? #CalculateWithMonteCarlo
|
let chooseConvolutionOrMonteCarlo = (
|
||||||
: #CalculateWithConvolution
|
op: Operation.algebraicOperation,
|
||||||
|
t2: t,
|
||||||
|
t1: t,
|
||||||
|
): calculationMethod =>
|
||||||
|
switch op {
|
||||||
|
| #Divide
|
||||||
|
| #Power
|
||||||
|
| #Logarithm =>
|
||||||
|
MonteCarlo
|
||||||
|
| (#Add | #Subtract | #Multiply) as convOp =>
|
||||||
|
expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > 10000
|
||||||
|
? MonteCarlo
|
||||||
|
: Convolution(convOp)
|
||||||
|
}
|
||||||
|
|
||||||
let run = (
|
let run = (
|
||||||
t1: t,
|
t1: t,
|
||||||
|
@ -207,17 +220,10 @@ module AlgebraicCombination = {
|
||||||
| Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist))
|
| Some(Ok(symbolicDist)) => Ok(Symbolic(symbolicDist))
|
||||||
| Some(Error(e)) => Error(Other(e))
|
| Some(Error(e)) => Error(Other(e))
|
||||||
| None =>
|
| None =>
|
||||||
switch arithmeticOperation {
|
switch chooseConvolutionOrMonteCarlo(arithmeticOperation, t1, t2) {
|
||||||
| #Divide
|
| MonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2)
|
||||||
| #Power
|
| Convolution(convOp) =>
|
||||||
| #Logarithm =>
|
runConvolution(toPointSetFn, convOp, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet(r))
|
||||||
runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2)
|
|
||||||
| (#Add | #Subtract | #Multiply) as op =>
|
|
||||||
switch chooseConvolutionOrMonteCarlo(t1, t2) {
|
|
||||||
| #CalculateWithMonteCarlo => runMonteCarlo(toSampleSetFn, arithmeticOperation, t1, t2)
|
|
||||||
| #CalculateWithConvolution =>
|
|
||||||
runConvolution(toPointSetFn, op, t1, t2)->E.R2.fmap(r => DistributionTypes.PointSet(r))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user