tweak: Add error checking to dmr calculation
This commit is contained in:
parent
60e42cf1e8
commit
fc2d647b62
|
@ -272,6 +272,29 @@ module DiminishingReturns = {
|
||||||
1. O(n): Iterate through value on next n dollars. At each step, only compute the new marginal return of the function which is spent
|
1. O(n): Iterate through value on next n dollars. At each step, only compute the new marginal return of the function which is spent
|
||||||
2. O(n*m): Iterate through all possible spending combinations. The advantage of this option is that it wouldn't assume that the returns of marginal spending are diminishing.
|
2. O(n*m): Iterate through all possible spending combinations. The advantage of this option is that it wouldn't assume that the returns of marginal spending are diminishing.
|
||||||
*/
|
*/
|
||||||
|
switch (
|
||||||
|
E.A.length(lambdas) > 1,
|
||||||
|
funds > 0.0,
|
||||||
|
approximateIncrement > 0.0,
|
||||||
|
funds > approximateIncrement,
|
||||||
|
) {
|
||||||
|
| (false, _, _, _) =>
|
||||||
|
Error(
|
||||||
|
"Error in Danger.optimalAllocationGivenDiminishingMarginalReturnsForManyFunctions, number of functions should be greater than 1.",
|
||||||
|
)
|
||||||
|
| (_, false, _, _) =>
|
||||||
|
Error(
|
||||||
|
"Error in Danger.optimalAllocationGivenDiminishingMarginalReturnsForManyFunctions, funds should be greater than 0.",
|
||||||
|
)
|
||||||
|
| (_, _, false, _) =>
|
||||||
|
Error(
|
||||||
|
"Error in Danger.optimalAllocationGivenDiminishingMarginalReturnsForManyFunctions, approximateIncrement should be greater than 0.",
|
||||||
|
)
|
||||||
|
| (_, _, _, false) =>
|
||||||
|
Error(
|
||||||
|
"Error in Danger.optimalAllocationGivenDiminishingMarginalReturnsForManyFunctions, approximateIncrement should be smaller than funds amount.",
|
||||||
|
)
|
||||||
|
| (true, true, true, true) => {
|
||||||
let applyFunctionAtPoint = (lambda, point: float) => {
|
let applyFunctionAtPoint = (lambda, point: float) => {
|
||||||
// Defined here so that it has access to environment, reducer
|
// Defined here so that it has access to environment, reducer
|
||||||
let pointAsInternalExpression = FunctionRegistry_Helpers.Wrappers.evNumber(point)
|
let pointAsInternalExpression = FunctionRegistry_Helpers.Wrappers.evNumber(point)
|
||||||
|
@ -355,9 +378,8 @@ module DiminishingReturns = {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimalAllocationResult
|
optimalAllocationResult
|
||||||
// let result = [0.0, 0.0]->FunctionRegistry_Helpers.Wrappers.evArrayOfEvNumber->Ok
|
}
|
||||||
// result
|
}
|
||||||
// ^ helper with the same type as what the result should be. Useful for debugging.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module Lib = {
|
module Lib = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user