[orx-gradient-descent] convert to MPP
This commit is contained in:
@@ -175,12 +175,3 @@ fun minimize(_x0: DoubleArray,
|
||||
return MinimizationResult(x0, f0, g0, H1, iteration)
|
||||
}
|
||||
|
||||
fun <T : Any> minimizeModel(model: T, endOnLineSearch: Boolean = false, tol: Double = 1e-8, maxIterations: Int = 1000, function: (T) -> Double) {
|
||||
val doubles = modelToArray(model)
|
||||
val weights = DoubleArray(doubles.size) { 1.0 }
|
||||
val solution = minimize(doubles, weights, endOnLineSearch, tol, maxIterations) {
|
||||
arrayToModel(it, model)
|
||||
function(model)
|
||||
}
|
||||
arrayToModel(solution.solution, model)
|
||||
}
|
||||
12
orx-gradient-descent/src/jvmMain/kotlin/GradientDescent.kt
Normal file
12
orx-gradient-descent/src/jvmMain/kotlin/GradientDescent.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
@file:JvmName("GradientDescentJvmKt")
|
||||
package org.openrndr.extra.gradientdescent
|
||||
|
||||
fun <T : Any> minimizeModel(model: T, endOnLineSearch: Boolean = false, tol: Double = 1e-8, maxIterations: Int = 1000, function: (T) -> Double) {
|
||||
val doubles = modelToArray(model)
|
||||
val weights = DoubleArray(doubles.size) { 1.0 }
|
||||
val solution = minimize(doubles, weights, endOnLineSearch, tol, maxIterations) {
|
||||
arrayToModel(it, model)
|
||||
function(model)
|
||||
}
|
||||
arrayToModel(solution.solution, model)
|
||||
}
|
||||
Reference in New Issue
Block a user