tweak: format
This commit is contained in:
parent
8f8ca02730
commit
9551aae634
|
@ -214,8 +214,9 @@ module Internals = {
|
||||||
let increment = funds /. numDivisions
|
let increment = funds /. numDivisions
|
||||||
let arrayOfIncrements = Belt.Array.makeBy(numDivisionsInt, _ => increment)
|
let arrayOfIncrements = Belt.Array.makeBy(numDivisionsInt, _ => increment)
|
||||||
|
|
||||||
let findBiggestElementIndex = (xs) => E.A.reducei(xs, 0, (acc, newElement, index) => {
|
let findBiggestElementIndex = xs =>
|
||||||
switch(newElement > xs[acc]){
|
E.A.reducei(xs, 0, (acc, newElement, index) => {
|
||||||
|
switch newElement > xs[acc] {
|
||||||
| true => index
|
| true => index
|
||||||
| false => acc
|
| false => acc
|
||||||
}
|
}
|
||||||
|
@ -231,19 +232,21 @@ module Internals = {
|
||||||
acc,
|
acc,
|
||||||
newIncrement,
|
newIncrement,
|
||||||
) => {
|
) => {
|
||||||
switch(acc){
|
switch acc {
|
||||||
| Ok(accInner) => {
|
| Ok(accInner) => {
|
||||||
let oldMarginalReturnsWrapped = accInner.currentMarginalReturns
|
let oldMarginalReturnsWrapped = accInner.currentMarginalReturns
|
||||||
let newAccWrapped = switch(oldMarginalReturnsWrapped){
|
let newAccWrapped = switch oldMarginalReturnsWrapped {
|
||||||
| Ok(oldMarginalReturns) => {
|
| Ok(oldMarginalReturns) => {
|
||||||
let indexOfBiggestDMR = findBiggestElementIndex(oldMarginalReturns)
|
let indexOfBiggestDMR = findBiggestElementIndex(oldMarginalReturns)
|
||||||
let newOptimalAllocations = Belt.Array.copy(accInner.optimalAllocations)
|
let newOptimalAllocations = Belt.Array.copy(accInner.optimalAllocations)
|
||||||
let newOptimalAllocationsi =
|
let newOptimalAllocationsi = newOptimalAllocations[indexOfBiggestDMR] +. newIncrement
|
||||||
newOptimalAllocations[indexOfBiggestDMR] +. newIncrement
|
|
||||||
newOptimalAllocations[indexOfBiggestDMR] = newOptimalAllocationsi
|
newOptimalAllocations[indexOfBiggestDMR] = newOptimalAllocationsi
|
||||||
let lambdai = indexOfBiggestDMR == 0 ? lambda1: lambda2 // to do: generalize
|
let lambdai = indexOfBiggestDMR == 0 ? lambda1 : lambda2 // to do: generalize
|
||||||
let newMarginalResultsLambdai = applyFunctionAtFloatToFloatOption(lambdai, newOptimalAllocationsi)
|
let newMarginalResultsLambdai = applyFunctionAtFloatToFloatOption(
|
||||||
let newCurrentMarginalReturns = switch(newMarginalResultsLambdai){
|
lambdai,
|
||||||
|
newOptimalAllocationsi,
|
||||||
|
)
|
||||||
|
let newCurrentMarginalReturns = switch newMarginalResultsLambdai {
|
||||||
| Ok(value) => {
|
| Ok(value) => {
|
||||||
let result = Belt.Array.copy(oldMarginalReturns)
|
let result = Belt.Array.copy(oldMarginalReturns)
|
||||||
result[indexOfBiggestDMR] = value
|
result[indexOfBiggestDMR] = value
|
||||||
|
@ -254,7 +257,7 @@ module Internals = {
|
||||||
|
|
||||||
let newAcc: diminishingReturnsAccumulatorInner = {
|
let newAcc: diminishingReturnsAccumulatorInner = {
|
||||||
optimalAllocations: newOptimalAllocations,
|
optimalAllocations: newOptimalAllocations,
|
||||||
currentMarginalReturns: newCurrentMarginalReturns
|
currentMarginalReturns: newCurrentMarginalReturns,
|
||||||
}
|
}
|
||||||
Ok(newAcc)
|
Ok(newAcc)
|
||||||
}
|
}
|
||||||
|
@ -264,7 +267,7 @@ module Internals = {
|
||||||
}
|
}
|
||||||
| Error(b) => Error(b)
|
| Error(b) => Error(b)
|
||||||
}
|
}
|
||||||
/*let findSmaller = (_) => 0
|
/* let findSmaller = (_) => 0
|
||||||
let smallerDMR =
|
let smallerDMR =
|
||||||
acc
|
acc
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user