tweak: save intermediary state
This commit is contained in:
parent
8bdfa03799
commit
70d9a5c9f3
|
@ -279,7 +279,7 @@ module Internals = {
|
|||
optimalAllocationResult
|
||||
}
|
||||
let diminishingMarginalReturnsForManyFunctions = (
|
||||
innerLambdas,
|
||||
lambdas,
|
||||
funds,
|
||||
approximateIncrement,
|
||||
environment,
|
||||
|
@ -290,18 +290,6 @@ module Internals = {
|
|||
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. Fun is, it doesn't assume that the returns of marginal spending are diminishing.
|
||||
*/
|
||||
let individuallyWrappedLambdas = E.A.fmap(possibleLambda =>
|
||||
switch possibleLambda {
|
||||
| ReducerInterface_InternalExpressionValue.IEvLambda(lambda) => Ok(lambda)
|
||||
| _ =>
|
||||
Error(
|
||||
"Error in diminishingMarginalReturnsForManyFunctions: One of the elements in the function array is not a function",
|
||||
)
|
||||
}
|
||||
, innerLambdas)
|
||||
let collectivelyWrappedLambdas = E.A.R.firstErrorOrOpen(individuallyWrappedLambdas)
|
||||
let result = switch collectivelyWrappedLambdas {
|
||||
| Ok(lambdas) => {
|
||||
let applyFunctionAtFloatToFloatOption = (lambda, point: float) => {
|
||||
// Defined here so that it has access to environment, reducer
|
||||
let pointAsInternalExpression = castFloatToInternalNumber(point)
|
||||
|
@ -321,6 +309,8 @@ module Internals = {
|
|||
}
|
||||
result
|
||||
}
|
||||
/*
|
||||
|
||||
let numDivisions = Js.Math.round(funds /. approximateIncrement)
|
||||
let numDivisionsInt = Belt.Float.toInt(numDivisions)
|
||||
let increment = funds /. numDivisions
|
||||
|
@ -378,13 +368,9 @@ module Internals = {
|
|||
| Ok(inner) => Ok(castArrayOfFloatsToInternalArrayOfInternals(inner.optimalAllocations))
|
||||
| Error(b) => Error(b)
|
||||
}
|
||||
optimalAllocationResult
|
||||
/*let result = [0.0, 0.0]->castArrayOfFloatsToInternalArrayOfInternals->Ok
|
||||
result*/
|
||||
}
|
||||
|
||||
| Error(b) => Error(b)
|
||||
}
|
||||
// optimalAllocationResult
|
||||
*/
|
||||
let result = [0.0, 0.0]->castArrayOfFloatsToInternalArrayOfInternals->Ok
|
||||
result
|
||||
}
|
||||
}
|
||||
|
@ -594,6 +580,56 @@ let library = [
|
|||
],
|
||||
(),
|
||||
),
|
||||
Function.make(
|
||||
~name="diminishingMarginalReturnsForManyFunctions",
|
||||
~nameSpace,
|
||||
~output=EvtArray,
|
||||
~requiresNamespace=false,
|
||||
~examples=[
|
||||
`Danger.diminishingMarginalReturnsForManyFunctions([{|x| x+1}, {|y| 10}], 100, 0.01)`,
|
||||
],
|
||||
~definitions=[
|
||||
FnDefinition.make(
|
||||
~name="diminishingMarginalReturnsForManyFunctions",
|
||||
~inputs=[FRTypeArray(FRTypeLambda), FRTypeNumber, FRTypeNumber],
|
||||
~run=(inputs, _, environment, reducer) =>
|
||||
switch inputs {
|
||||
| [IEvArray(innerlambdas), IEvNumber(funds), IEvNumber(approximateIncrement)] => {
|
||||
/*let individuallyWrappedLambdas = E.A.fmap(innerLambda => {
|
||||
switch innerLambda {
|
||||
| ReducerInterface_InternalExpressionValue.IEvLambda(lambda) => Ok(lambda)
|
||||
| _ =>
|
||||
Error(
|
||||
"Error in Danger.diminishingMarginalReturnsForManyFunctions. A member of the array wasn't a function",
|
||||
)
|
||||
}
|
||||
}, innerlambdas)
|
||||
let wrappedLambdas = E.A.R.firstErrorOrOpen(individuallyWrappedLambdas)
|
||||
let result = switch wrappedLambdas {
|
||||
| Ok(lambdas) => {
|
||||
let result = Internals.diminishingMarginalReturnsForManyFunctions(
|
||||
lambdas,
|
||||
funds,
|
||||
approximateIncrement,
|
||||
environment,
|
||||
reducer,
|
||||
)
|
||||
result
|
||||
}
|
||||
| Error(b) => Error(b)
|
||||
}
|
||||
result
|
||||
*/
|
||||
Error("wtf man")
|
||||
}
|
||||
| _ => Error("Error in Danger.diminishingMarginalReturnsForTwoFunctions")
|
||||
},
|
||||
(),
|
||||
),
|
||||
],
|
||||
(),
|
||||
),
|
||||
/*
|
||||
Function.make(
|
||||
~name="diminishingMarginalReturnsForManyFunctions",
|
||||
~nameSpace,
|
||||
|
@ -608,19 +644,24 @@ let library = [
|
|||
~inputs=[FRTypeArray(FRTypeLambda), FRTypeNumber, FRTypeNumber],
|
||||
~run=(inputs, _, env, reducer) =>
|
||||
switch inputs {
|
||||
| [IEvArray(innerlambdas), IEvNumber(funds), IEvNumber(approximateIncrement)] =>
|
||||
| [IEvArray(innerlambdas), IEvNumber(funds), IEvNumber(approximateIncrement)] => {
|
||||
let result = [0.0, 0.0]->Internals.castArrayOfFloatsToInternalArrayOfInternals->Ok
|
||||
result
|
||||
}
|
||||
/*
|
||||
Internals.diminishingMarginalReturnsForManyFunctions(
|
||||
innerlambdas,
|
||||
funds,
|
||||
approximateIncrement,
|
||||
env,
|
||||
reducer,
|
||||
)
|
||||
| _ => Error("Error in Danger.diminishingMarginalReturnsForTwoFunctions")
|
||||
)*/
|
||||
|
||||
| _ => Error("Error in Danger.diminishingMarginalReturnsForManyFunctions")
|
||||
},
|
||||
(),
|
||||
),
|
||||
],
|
||||
(),
|
||||
),
|
||||
),*/
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue
Block a user