Kotlin and linear programming(tomstechnicalblog.blogspot.com) |
Kotlin and linear programming(tomstechnicalblog.blogspot.com) |
No. As in G. Simmons, the two pillars of the field of 'analysis' in math are linearity and continuity. The two are quite different.
Linearity usually has to do with numbers and vectors. The numbers are usually in the set R of real numbers or the set C of complex numbers. Commonly the numbers are called scalars. Then, a function f is 'linear' provided for scalars a and b and vectors x and y we have
f(ax + by) = af(x) + bf(y)
The role, utility? It's an enormous, powerful simplification and, in particular, is crucial to systems (high school style) 'systems of linear equations', linearity, essentially 'super position', in quantum mechanics, and linear operators, as in the classic Dunford and Schwarz, e.g., as in the results of S. Banach. In calculus, differentiation and integration are both linear operators.
And, in particular, linearity is crucial in both linear programming and integer linear programming. Local linear approximations are crucial in non-linear optimization, e.g., the Kuhn-Tucker conditions and their associated constraint qualifications.
Continuity is also a biggie, e.g., for a function to be continuous on a compact set, e.g., [0,1], means it is also uniformly continuous, bounded, and achieves its greatest lower bound and least upper bound. Continuity, compactness, and uniform continuity are the standard assumptions that guarantee that the Riemann integral of freshman calculus exists.
Maybe what was meant was usually when we mention linear programming we have, say, find x to solve Ax = b, x >= 0 where x, where for positive integer n, is n x 1 and, thus, for the set of real numbers R, in the set R^n. Here the A is a matrix, say, for some positive integer m, m x n. Then from the beginnings of the start of matrix theory, for real a and b and n x 1 y we have
A(ax + by) = aAx + bAy
which says that A is a linear function (operator, transformation, etc.). That's the 'linearity' in linear programming. And it holds in linear integer programming where we ask that some or all of the components of x be integers.
Close. Linear programming is: minimize z = cx subject to Ax <= b. A and b customarily force x >= 0. Linear programming can be solved by application of the Simplex method or interior point methods. Integer linear programming constrains x to the integers, and mixed integer linear programming constrains only some of x to the integers. (x is a vector.) Integer linear programming problems are often optimized using branch and bound or branch and cut. The example in the article isn't great for these methods for a couple of reasons.
1. There's nothing to optimize. This is an assignment problem that's only about feasibility.
2. The constraints are pretty restrictive. Tree-based search can really spin its wheels trying to find feasible solutions.
Edit to add: Ax <= b is a system of linear inequalities, and z=cx is a linear equation. That's where the linearity comes in.
No. Sure, the objective function z = cx is linear. But far and away, what is just crucial, the real power that makes linear programming work, is the linearity of the matrix A. Then the feasible region is a finite intersection of closed half spaces and is convex with flat sides and extreme points. To find optimal solutions, it is sufficient to look only at the extreme points, and there are only finitely many of those.
We can do a lot of relaxing of the objective function and still do well; relaxing the linearity of the constraints promises to give us much more trouble.
I feel like Kotlin is almost exactly the wrong language in this space. You either go all the way to a more powerfully typed language where Scala has grabbed mindshare, or you go fully towards dynamic languages like Python or (my favorite, even though it has almost no mindshare in this space), Groovy. It really feels like all Kotlin did here was add verbosity and cloud the actual question being answered with more syntax.
https://www.atlassian.com/blog/archives/scala-types-of-a-hig...
No, linear programming is an applied field of mathematics that attempts to find an optimal solution to a goal within a system which is under some sort of constraint(s). Whether those constraints are business constraints is irrelevant; the theory exists outside of any particular application.
http://tomstechnicalblog.blogspot.com/2018/01/kotlin-for-lin...
Without these tricks the technique is pretty limited at solving real world problems.
To an extent. The basic algorithms are well known (simplex, interior point), but there is a lot of scope for improvements - this is why the big commercial solvers can be orders of magnitude faster than the best open source ones. Still, even if the algorithms are not well-known, they do only need to be implemented once.
For integer programming, though, there can definitely be value in problem-specific heuristics for branch selection and rounding.
I know JVM optimizes small methods, so maybe their JIT optimizer does that automatically, but I'm not sure that optimizer is better that manually optimized code like in numpy.
Unlike .Net with System.Numerics.Vectors, they're not even interested in making a platform-independent SIMD library for manual optimisation. The JVM holds contempt for such real-world optimisations. I see that Intel have made one though - https://software.intel.com/en-us/articles/vector-api-develop...
At a glance, it looks like Oracle have dabbled with AVX in HotSpot, but aren't taking it very seriously. https://www.google.com/search?q="-XX%3AUseAVX"
Take spark, for instance. You run into extreme performance issues the second your data has to be serialized to cross the py4j gap. An many essential parts of its API require scala/java (presumably Kotlin ought to work as well).
Similar situations occur all across the big data and cloud realm, with python. And then even still today.. you'll run into situations where whizzbang data science ml library that solves your exact problem.. for some reason is python 2.7 only. Thankfully that situation is getting rarer (there really isn't an excuse for it today) - but its still there.
In any case, a "not-java" language that can talk java is freakin amazing, in my book (Scala doesn't scratch my itch there - it's far too clever - had enough of that with perl back in the day).
Clojure is a bunch simpler than Scala, many Python programmers are quick to pick it up. The dynamic nature and interactive prompt is all there.
If you look at Norvig's Python-Lisp comparison table at http://norvig.com/python-lisp.html - all the red cells (where Lisp lost to Python) are fixed in Clojure.
I don't understand why this is such a big draw for people when literally any jvm language[1] has this feature. Languages like jython, ABCL, clojure, jruby, groovy, and perl6. Kotlin is certainly not unique in this regard.
Currently Python took a niche between quick ad-hoc exploration tasks (land of R) and production pipelines (land of JVM/C#/C++), but for large pipelines it's not so suitable IMO.
That's why I like dynamic typing. Coupled with Python's type annotations for hard cases and good documentation, dynamic typing allows you to go further by reducing cognitive load.
There are .NET CUDA implementations as well.
For example, on Android, Java is the name of the game, beyond 3D rendering and audio codecs, the NDK is quite useless as everything else is exposed behind JNI calls.
To me "complicated" means that the rules of a system require a lot of information to describe, i.e. it has a lot of special cases and caveats to learn. Whereas "complex" is more about the variety of emergent patterns in a system which are necessary to understand it and interact with it effectively.
As an example, rules of Go are very simple, but we probably wouldn't call it a simple game. In contrast, the rules of Chess are rather more involved, with quite a few special cases. Both games can be called "complex", but I'd also say that Chess is more complicated.
So using these terms, it sounds like you're saying Scala is less complicated than Kotlin, whereas the parent is perhaps saying that Kotlin is less complex?
That being said, having gone through at least one book, and have read lots of code - I still find it very difficult to parse in my brain.
It feels more complex to me, because there seems like there are so many implicit things going on, where something like Kotlin makes efforts to be explicit (yet still strikes a nice level of conciseness). But that could also be my inexperience with scala.
Having different syntax for different kinds of effect as Kotlin does could be seen as more explicit I guess, but I find it actually makes it harder to work with - you have a lot more syntax to keep in your head, and you can't write generic code that works with multiple different effects. Other than that I don't think there's anything more explicit in Kotlin, and some things - error handling in particular - are definitely less explicit.
Some of the languages you mention come with serious compromises when used on the JVM, like Jython and Jruby - decent portions of their ecosystems are implemented in C - and hence won't work on the JVM.
It's notable that projects like spark could have used Jython for its JVM/python interop, but chose py4j instead, consigning pyspark to some rather abysmal performance penalties under many conditions.
I'm not sure either. Your comment seems perfectly legitemate to me...