All Projects → optimatika → Okalgo

optimatika / Okalgo

Licence: mit
Idiomatic Kotlin extensions for ojAlgo

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Okalgo

Quant Notes
Quantitative Interview Preparation Guide, updated version here ==>
Stars: ✭ 180 (+800%)
Mutual labels:  linear-algebra, optimization
Cpmoptimize
🚀 🐍 Optimizes Python bytecode calculating linear recurrences
Stars: ✭ 159 (+695%)
Mutual labels:  linear-algebra, optimization
Owl
Owl - OCaml Scientific and Engineering Computing @ http://ocaml.xyz
Stars: ✭ 919 (+4495%)
Mutual labels:  linear-algebra, optimization
Tiramisu
A polyhedral compiler for expressing fast and portable data parallel algorithms
Stars: ✭ 685 (+3325%)
Mutual labels:  linear-algebra, optimization
Ojalgo
oj! Algorithms
Stars: ✭ 336 (+1580%)
Mutual labels:  linear-algebra, optimization
Peroxide
Rust numeric library with R, MATLAB & Python syntax
Stars: ✭ 191 (+855%)
Mutual labels:  linear-algebra, optimization
Gosl
Linear algebra, eigenvalues, FFT, Bessel, elliptic, orthogonal polys, geometry, NURBS, numerical quadrature, 3D transfinite interpolation, random numbers, Mersenne twister, probability distributions, optimisation, differential equations.
Stars: ✭ 1,629 (+8045%)
Mutual labels:  linear-algebra, optimization
Simpeg
Simulation and Parameter Estimation in Geophysics - A python package for simulation and gradient based parameter estimation in the context of geophysical applications.
Stars: ✭ 283 (+1315%)
Mutual labels:  linear-algebra, optimization
Teaching
Teaching Materials for Dr. Waleed A. Yousef
Stars: ✭ 435 (+2075%)
Mutual labels:  linear-algebra, optimization
Liblaml
A stand-alone pure C++ library for linear algebra and machine learning
Stars: ✭ 7 (-65%)
Mutual labels:  linear-algebra, optimization
Vs Net
Variable splitting network for accelerated parallel MRI reconstruction
Stars: ✭ 22 (+10%)
Mutual labels:  optimization
Rl Baselines Zoo
A collection of 100+ pre-trained RL agents using Stable Baselines, training and hyperparameter optimization included.
Stars: ✭ 839 (+4095%)
Mutual labels:  optimization
Suitesparse
SuiteSparse: a suite of sparse matrix packages by T. A. Davis et al. (This repository contains copies of the official versions.)
Stars: ✭ 19 (-5%)
Mutual labels:  linear-algebra
Bfgs Neldermead Trustregion
Python implementation of some numerical (optimization) methods
Stars: ✭ 8 (-60%)
Mutual labels:  optimization
Shift Scheduling
Shift Scheduling for workforce
Stars: ✭ 22 (+10%)
Mutual labels:  optimization
Powermodelsannex.jl
A PowerModels.jl Extension Package for Exploratory Work
Stars: ✭ 11 (-45%)
Mutual labels:  optimization
Forte
Designing generative structures by interactive sketching
Stars: ✭ 25 (+25%)
Mutual labels:  optimization
Wheels
Performance-optimized wheels for TensorFlow (SSE, AVX, FMA, XLA, MPI)
Stars: ✭ 891 (+4355%)
Mutual labels:  optimization
Tess Opt
Demonstration of how we can use tessellation shaders to make faster fragment shaders.
Stars: ✭ 13 (-35%)
Mutual labels:  optimization
Cutest.jl
Julia's CUTEst Interface
Stars: ✭ 10 (-50%)
Mutual labels:  optimization

okAlgo

Idiomatic Kotlin extensions for ojAlgo, with some inspirations from PuLP.

Linear Algebra DSL

Below is an example of how to use the linear algebra DSL. In this particular example, we create a Markov chain to calculate the probability of 5 consecutive heads in 10 coin flips.

import org.ojalgo.okalgo.populate
import org.ojalgo.okalgo.primitivematrix
import org.ojalgo.okalgo.times

fun main() {
	
	val transitionMatrix = primitivematrix(rows = 6, cols = 6) {
		populate {row, col ->
			when {
				col == 0L -> .50
				row + 1L == col -> .50
				row == 5L && col == 5L -> 1.0
				else -> 0.0
			}
		}
	}

	println("\r\nTransition Matrix:")
	println(transitionMatrix)

	val toTenthPower = generateSequence(transitionMatrix) { it * transitionMatrix }.take(10).last()
	println("\r\nTransition Matrix Raised to 10th Power")
	println(toTenthPower)

	println("\r\nMARKOV CHAIN RESULT: ${toTenthPower[0,5]}")
}

// REFERENCE: https://www.quora.com/What-is-the-probability-of-getting-5-consecutive-heads-in-10-tosses-of-a-fair-coin

OUTPUT:

Transition Matrix:
org.ojalgo.matrix.PrimitiveMatrix < 6 x 6 >
{ { 0.5,	0.5,	0.0,	0.0,	0.0,	0.0 },
{ 0.5,	0.0,	0.5,	0.0,	0.0,	0.0 },
{ 0.5,	0.0,	0.0,	0.5,	0.0,	0.0 },
{ 0.5,	0.0,	0.0,	0.0,	0.5,	0.0 },
{ 0.5,	0.0,	0.0,	0.0,	0.0,	0.5 },
{ 0.5,	0.0,	0.0,	0.0,	0.0,	1.0 } }

Transition Matrix Raised to 10th Power
org.ojalgo.matrix.PrimitiveMatrix < 6 x 6 >
{ { 0.5546875,	0.267578125,	0.1298828125,	0.0634765625,	0.03125,	0.109375 },
{ 0.6015625,	0.287109375,	0.1376953125,	0.06640625,	0.0322265625,	0.140625 },
{ 0.7109375,	0.333984375,	0.1572265625,	0.07421875,	0.03515625,	0.2041015625 },
{ 0.9609375,	0.443359375,	0.2041015625,	0.09375,	0.04296875,	0.333984375 },
{ 1.5244140625,	0.693359375,	0.3134765625,	0.140625,	0.0625,	0.6015625 },
{ 2.78125,	1.2568359375,	0.5634765625,	0.25,	0.109375,	1.15625 } }

MARKOV CHAIN RESULT: 0.109375

MIP Solver DSL

EXAMPLE 1

expressionsbasedmodel {

    val v1 = variable(lower = 3, upper = 6)
    val v2 = variable(lower = 10, upper = 12)

    expression(weight = 1) {
        set(v1, 1)
        set(v2, 1)
    }

    maximise()

    println("v1=${v1.value.toDouble()} v2=${v2.value.toDouble()}")
}

EXAMPLE 2

val model = ExpressionsBasedModel()
        
val v1 = model.variable(lower = 3, upper = 6)
val v2 = model.variable(lower = 10, upper = 12)

model.expression(weight=1) {
    set(v1, 1)
    set(v2, 1)
}

model.maximise()

println("v1=${v1.value.toDouble()} v2=${v2.value.toDouble()}")

Expression building with Kotlin extensions is also being explored:

EXAMPLE 3

expressionsbasedmodel {

    val v1 = variable(lower = 2, upper = 10, isInteger = true)
    val v2 = variable(lower = 2, upper = 10, isInteger = true)

    expression(v1 + 2*v2) {
        weight(1)
    }

    expression {
        set(v1 + v2 EQ 16)
    }

    minimise().run(::println)

    println("v1=${v1.value.toDouble()} v2=${v2.value.toDouble()}")
}

Artifact Instructions

Until this gets deployed to Maven Central, you can use JitPack to import this project as a dependency.

Maven

<dependency>
    <groupId>org.ojalgo</groupId>
    <artifactId>okalgo</artifactId>
    <version>0.0.2</version>
</dependency>

Gradle

compile 'org.ojalgo:okalgo:0.0.2'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].