Live data from Hacker News

Ask HN: Do you use an optimization solver? Which one? Do you like it?

news.ycombinator.com

111–120 of 158 posts

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#111
post #102

At my current job we use Optaplanner in a project, to move around seat reservations (in blocks of several hundred) whilst keeping the new seats as similar as possible to the old ones (each seat having 'attributes' with various weights). I mostly chose it due to being JVM (although it needed a little Java shim to make it usable from Scala) In grad school I used MiniZinc to find exact optimal subsets for a certain prob…

I’m curious to know how your experience with Optaplanner has been. As I understand you model your problems quite differently and it is more of a search for a good enough solution using metaheuristics?

I think Optaplanner has its own DSL, but we use the Java/JVM API: a 'solution' is just a normal JVM object, which references other objects in the usual way. Certain fields are annotated, which tells Optaplanner that it can mutate/alter them.

Implementing the domain objects is pretty natural. The only part that feels weird is that solving is completely based around mutation; whilst that's pretty idiomatic for Java, it feels a bit alien in Scala (I previously worked mostly in Haskell, and haven't written Java in over a decade).

There's a bunch of configuration boilerplate; including the following, which is the only Java code in the whole project (and almost looks like a parody of "Enterprise Java"!):

    class Config {
        public static ScoreDirectorFactoryConfig config =
            (new ScoreDirectorFactoryConfig())
            .withEasyScoreCalculatorClass(ScoreCalculator.class);
    }
IIRC, this had to be Java due to some weird self-referential interface that makes Scala's type-checker explode.

We can give each solution both a "hard" score and a "soft" score, where the soft score will be sacrificed if it improves the hard score. We use the hard score to count errors which make a solution invalid (e.g. trying to assign two people to the same seat); and the soft score as a weighted sum of mismatched seat attributes (e.g. it would be nice to stay facing the same direction; but not crucial).

Once the problem has been defined, it can be sent to a bunch of solvers; we use simulated annealing with a timeout. Since it's an anytime-algorithm, we can adjust the timeout to however long we're prepared to wait.

To avoid "obvious" problems in Optaplanner's results, we send them through a simple hill-climbing loop to ensure we're at a local maximum.

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#112

After several years of exploring, my current gotos are: * Minion for IP for scheduling + edge crossing minimization. * cvxpy (wrapping ECOS, OSQP, and SCS by default) for convex optimization for making nice geometry. * Z3 and STP for SAT/SMT for program analysis. All are FLOSS, which is my main criterion in many situations. Beyond that, I like minion for its focus on only providing efficiently implementable primitive…

I'm curious what kind of person has 3 favorite constraint optimizers. What do you do that has you making use of so many different ones?

Decade+ CISO of Akamai, math bent. http://www.mstone.info/resume/resume.pdf

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#113
post #90

Earlier quoted context omitted.

would you be able to offer some examples and some discussion of how to choose?

https://link.springer.com/book/10.1007/978-1-4419-1665-5

Great coverage — simulated annealing, genetic algorithms, ant colony optimization.

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#114

Earlier quoted context omitted.

would you be able to offer some examples and some discussion of how to choose?

Genetic algorithms are known to produce quasi-optimal results in a short time, if set up accordingly. They can be also applied to problems where constraints are very complex to explicitly formulate. Designing one is no picnic, though, and always problem-specific.

Interesting.

What do you mean by quasi optimal?

Genetic algorithms product quasi optimal results but simulated annealing will not?

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#115

Earlier quoted context omitted.

I'm curious what kind of person has 3 favorite constraint optimizers. What do you do that has you making use of so many different ones?

Decade+ CISO of Akamai, math bent. http://www.mstone.info/resume/resume.pdf

Yep, that'll do it. :) Thanks!

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#117
- Cplex and Gurobi, sometimes some open source ones.

- Energy modelling: the core models for one timestep are small (ca 1-2k variables), but together with long timescales/stochastic programming the model formulation blows up (easily by a factor of 10-40k).

- Mostly LP-relaxations of MILPs with manual cuts. MILPs themselves take often too long.

- The solvers are ok:

  - There is a nice theory around LPs and MILP is understandable. So in principle, I trea them as black boxes.

  - API: Similar enough between solvers because of nice formalism of MILP. Generic APIs on most platforms (pyomo, jump, ..). Beware magical helpers.

  - Performance: For LP predictable. For MILP -- tune it. It becomes tricky when tuning solvers/staying solver-independent without sacrificing performance. Metaheuristics to the rescue. Open source solvers have a harder time here.
- The big problem is the modelling and context part: translating the problem into am MP formulation, ensuring correctness of units/scales, generation of apis and docs ... once you do it by hand, but if you want to run a modeling loop or support multiple models (variants, optimisations, special cases), then this ist most of the effort (and costs human time, instead of computing time).

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#118
I've used custom made implementation in Java ( proprietary based on the owner thesis ) to optimize train crossings for big mining companies like Vale, BHP and Rio tinto, it was stressful but super fun work!

Lot's of money to be made on it too if you guys are interested, but it's super niche and hard to get into. There is a huge resistence from train controllers and other workers. I actually understand it because of the job loss involved but it was super cool being in a NASA like control center sorrounded by panels and monitors and seeing the trains moving based on code I and other wrote!

It was a just in time local optimization with lots of heuristics and business rules embedded into it. Basically impossible to reuse between companies or even railroads sometimes, the controller would then solve all the more complex crossing that involved either some lose-lose choice or a pre-defined business decision.

The train controllers are amazing at their jobs, it's super stressful and a single mistake can kill people or make the whole thing stop for weeks, with the software running it made it a lot less risky, one dude could control an area that needed 7 or more people without it, with minor interventions.

Re: Ask HN: Do you use an optimization solver? Which one? Do you like it?

#120
post #42
post #2

I would love to use one or more but the process to convert business logic to solver is painful so I ended up having to write a simulated annealing algo in Rust instead. I tried solver.com, Google OR-Tools, and a few other utilities. It was much easier to build a score-calculator for min/max based on user-tweaked parameters, then, jiggle the data, re-calculate score, and keep doing it until there was significant impro…

> so I ended up having to write a simulated annealing algo I think there are much better algorithms in metaheuristic search than just simulated annealing.

cplex comes with a great heuristic now (odh), and gurobi too.
Post reply on HN