KeLPie is a Kotlin linear program library which allows you to create complicated, functional, non-canonical linear programs with ease.
Usage in 19 lines of code:
// Example problem from Professor James Jones at Richland University
// URL: https://people.richland.edu/james/ictcm/2006/
import krilis.solver.*
fun main() {
val x1 = ContinuousVar("x1")
val x2 = ContinuousVar("x2")
val solution = LpSolver(
maximize = 40.0*x1 + 30.0*x2,
subjectTo = arrayListOf(
LteConstraint(x1 + 2.0*x2, 16.0),
LteConstraint(x1 + x2, 9.0),
LteConstraint(3.0*x1 + 2.0*x2, 24.0),
GteConstraint(x1.toLinearExpr(), 0.0),
GteConstraint(x2.toLinearExpr(), 0.0)
)
).simplexSolve()
if (solution is OptimalSolution) {
println(solution.getValue(x1))
// Prints "6.0"
}
}
A more detailed tutorial can be found here.
A: Kotlin e Linear Program interface.