This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pulp | |
| # Code for this walkthrough: http://benalexkeen.com/linear-programming-with-python-and-pulp-part-3/ | |
| model = pulp.LpProblem("Profit maximising problem", pulp.LpMaximize) | |
| # Declare variables | |
| A = pulp.LpVariable('A', lowBound=0, cat='Integer') | |
| B = pulp.LpVariable('B', lowBound=0, cat='Integer') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.nield.kotlinstatistics | |
| import org.apache.commons.math3.optim.MaxIter | |
| import org.apache.commons.math3.optim.linear.* | |
| import org.apache.commons.math3.optim.nonlinear.scalar.GoalType | |
| /* | |
| Linear optimization with Apache Commons Math and Kotlin | |
| Original problem: http://benalexkeen.com/linear-programming-with-python-and-pulp-part-3/ | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.ojalgo.netio.BasicLogger | |
| import org.ojalgo.optimisation.ExpressionsBasedModel | |
| import org.ojalgo.optimisation.Variable | |
| // https://github.com/optimatika/ojAlgo/wiki/The-Diet-Problem | |
| fun main(args: Array<String>) { | |
| BasicLogger.debug() | |
| BasicLogger.debug(OjAlgoUtils.getTitle()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.ojalgo.optimisation.ExpressionsBasedModel | |
| import org.ojalgo.optimisation.Variable | |
| import java.math.RoundingMode | |
| // PROBLEM DESCRIBED HERE: http://benalexkeen.com/linear-programming-with-python-and-pulp-part-4/ | |
| fun main(args: Array<String>) { | |
| val model = ExpressionsBasedModel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.nield | |
| import org.ojalgo.optimisation.ExpressionsBasedModel | |
| import org.ojalgo.optimisation.Variable | |
| import java.util.concurrent.atomic.AtomicInteger | |
| // declare ojAlgo Model | |
| val model = ExpressionsBasedModel() | |
| // custom DSL for model expression inputs, eliminate naming and adding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Try to use explicit data classes, but if you want to quickly create tuples these will help | |
| */ | |
| data class Tuple2<out A, out B>(val a: A, val b: B) | |
| data class Tuple3<out A, out B, out C>(val a: A, val b: B, val c: C) | |
| data class Tuple4<out A, out B, out C, out D>(val a: A, val b: B, val c: C, val d: D) | |
| data class Tuple5<out A, out B, out C, out D, out E>(val a: A, val b: B, val c: C, val d: D, val e: E) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ds,y | |
| 2015-01-12 06:26:00,101 | |
| 2015-01-12 06:11:00,85 | |
| 2015-01-12 05:23:00,67 | |
| 2015-01-12 07:40:00,87 | |
| 2015-01-12 10:10:00,81 | |
| 2015-01-12 03:24:00,76 | |
| 2015-01-12 01:41:00,75 | |
| 2015-01-12 02:37:00,66 | |
| 2015-01-12 08:29:00,110 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun <T,R> Observable<T>.switchReplaySingle(cachedSingle: (T) -> Single<R>) = | |
| map { cachedSingle(it).toObservable().replay(1).autoConnect().firstOrError() } | |
| .replay(1) | |
| .autoConnect() | |
| .take(1) | |
| .flatMapSingle { it } | |
| .firstOrError() | |
| fun <T,R> Flowable<T>.switchReplaySingle(cachedSingle: (T) -> Single<R>) = | |
| map { cachedSingle(it).toObservable().replay(1).autoConnect().firstOrError() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main(args: Array<String>) { | |
| val markets = listOf( | |
| OD("ABQ","PHX"), | |
| OD("DAL", "HOU"), | |
| OD("HOU", "PHX") | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.reactivex.disposables.CompositeDisposable | |
| import io.reactivex.disposables.Disposable | |
| import io.reactivex.schedulers.Schedulers | |
| import java.util.concurrent.TimeUnit | |
| import java.util.concurrent.atomic.AtomicBoolean | |
| import java.util.concurrent.atomic.AtomicReference | |
| import kotlin.reflect.KProperty | |
| /** |