Are there Linear Programming libraries with the Simplex algorithm for Clojure? - algorithm

The Stigler Diet problem is a Linear Programming problem. It takes a list of foods and their nutritional values and solves for an optimized selection and quantities that meet objectives and constraints. Are there clojure libraries for Linear Programming - Simplex Algorithm, other than levand/prolin to work this?

Actually there is a clojure library: prolin uses the Simplex implementation provided by Apache Commons Math. It's probably the most idiomatic api in clojure for linear programming. Current version in github uses org.apache.commons.math3 v3.2, however according to this JIRA entry the simplex implementation has significantly been improved in v3.3, so it may be worth upgrading (see prolin issue #1).
Also of interest is the Java Constraint Programming API (JSR 331). There's a clojure project using that API. Although its name hints towards constraint programming (CP), this blog post talks about using it for accessing linear programming (LP) solvers such as GLPK, lp_solve, gurobi, etc.

The java JaCoP constraint programming library implements among others the Simplex algorithm. For Clojure, there's the CloCoP clojure wrapper over JaCoP.
Clojure's core.logic also has options for constraint programming.

Related

Independent algorithm implementation irrespective of what it is targeting

I am wondering if there is any architecture or guidelines already existing for defining algorithms and problems in way then can addressed N->N on demand. I have developed many algorithms (like brute Force, specialized to some paper) for solving problems. I found that I was doing repetitive work since algorithm and problem are interweaved in implementation to define solution. May be my approach is not best in implementation but I am getting what I wanted.
I am looking for architecture reference or guidelines for general basis algorithm(s) implementation and defining problems separate. So that an already implemented algorithm can be used to solve new problem. This way I can write algorithms like API, and use them when ever a problem need to be solved.
Any references would be great. I don't bother about programming platform since I can adapt to it in no time.

Searching for Genetic Programming framework/library

I am looking for framework, or library that could enable working with genetic programming (koza's style) not only by using mathematical functions, but also with loops, variable or constant assignment, object creations, or functions calling. I am not sure if there exists such branch of genetic algorithms and if it has a name.
I did my best in looking for informations, though the internet is poor with information on that specific topic.
HeuristicLab has a powerful implementation of Genetic Programming. It includes problems such as Symbolic Regression, Symbolic Classification, Time Series, Santa Fe Ant Trail, and there is a tutorial to implement custom problems such as the Lawn Mower (which is similar to the Santa Fe Ant Trail). HeuristicLab is implemented in C# and runs on Windows. It's released under GPL and can be freely downloaded.
The implementation of GP is very flexible and extensible, but also performance optimized using online calculations to avoid array allocation and memory overheads. We do include several benchmark problem instances for symbolic regression and classification. There are also more algorithms available such as Random Forests, Neural Networks, k-NN, SVM (if you're doing regression or classification).

parallel iterative algorithms for solving Linear System of Equations

Does someone know any library or ready source code of parallel implementation of quick iterative methods (bicgstab, CG, etc) for solving Linear System of Equations for example using MPI or OpenMP?
PetSC is a good example (both serial and MPI, and with a large library of linear and nonlinear solvers either included or provided as interfaces to external libraries). Trillinos is another example, but it's a much broader project and not as nicely integrated as PetSC. Aztec has a number of solvers, as does Hypre, which is hybrid (MPI+OpenMP).
These are all MPI-based at least in part; I don't know of too many OpenMP-enabled ones, although google suggests Lis, which I'm not familiar with.
Chapter 7 of Parallel Programming for Multicore and Cluster Systems contains algorithms for systems of linear equations, with source code (MPI).

Extensive Recursion Tutorial

Some problems that require recursion have always put me in a fix. I am not always able to come up with a recursive algorithm, but I know that there is a recursive solution to the problem.
I find problems like factorial and fibonacci easy to implement using recursive approach. But when I face more complex problems such as generating the partition of a number http://en.wikipedia.org/wiki/Partition_%28number_theory%29, I know that there is a possible recursive approach but I get stuck right there. I can't devise a recursive algorithm. Suppose I want to print all combinations of a string or if I want to bruteforce a Coin Change problem using recursion, I can't devise a recursive approach.
Is there any particular way to think so as to come up with a recursive approach? Is there any extensive recursive algorithms tutorial out there which can help me solve more advanced problems?
Look through the Structure and Interpretation of Computer Programs book, which is highly recommended here on Stack Overflow and is freely available online. It uses the Scheme programming language to teach fundamental concepts about programming. Since Scheme is a functional programming language, recursion is widely used everywhere - not only where you would use it even in imperative programming languages such as C or PHP, but also where you would typically use a looping construct. The examples and problems in the book present recursion in its natural habitat, if you will, and not through convoluted made-up scenarios.

Implementation of Johnson's algorithm to find elementary circuits (cycles) in a graph

Does anyone have source code implementing this algorithm for finding cycles, preferably in a modern statically-typed language like SML, OCaml, Haskell, F#, Scala?
The following is a Java implementation of the algorithm you need:
https://github.com/1123/johnson. Java running on the JVM, you can also use it from Scala.
I struggled on this too, I came up with this page that lists some implementations for Johnson algorithm (the one looking for elementary circuits) in Java and OCaml. The author of the blog post fixed some issues in the original implementations, on the same page I linked before there are also the fixed versions of both implementations.
You can find it here as part of jgrapht implementation.
Will C++ and Boost Graph Library work for you?

Resources