Live data from Hacker News

Using OR-Tools CP-SAT for Scheduling Problems

atalaykutlay.com

11–20 of 31 posts

Re: Using OR-Tools CP-SAT for Scheduling Problems

#11
post #9
post #8

Although this post discusses Constraint Programming - Satisfiability (CP-SAT) Solvers and Mixed Integer Problem (MIP) Solvers, it does not discuss Metaheuristic Solvers. Metaheuristic solvers are different in that you don't need to model your problem as a mixed integer problem. Instead, all it cares about is having a function that returns something you can compare. This allows you to model your problem however you li…

Interesting! Could you give example of problems you're using this for, to get an idea of where they'd be best suited?

If I understand them correctly, they're saying to use standard, optimization methods after writing a fitness or evaluation function to score your possible solutions. Which is a normal, non-SAT way of doing optimization.

So, you could use it for any application you saw benefit from genetic algorithms, simulated annealing, or tabu search. You can even use those to optimize neural networks without backpropagation and with fewer, local optima. Many papers on this but it's computationally heavier.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#12

I use CP-SAT for automated design problems. I need a guarantee on solution quality, so gen AI is a nonstarter. The problem formulation is quite messy and has constraints that can vary by locale. CP-SAT handles it pretty well. The one thing I've been trying to model well are cover constraints where for each x : xs, there is some y : ys st. pred(x, y). I've tried both boolean matrices and index constraints, and they wo…

Is it a geometric problem, like every point must reside within the plane? Are you optimizing also, like finding the smallest bounding box that includes the most points? You can usually express these as global constraints, like non-overlapping intervals, or you can use these to precompute feasible candidates rather than manually encoding giant matrices that contain knowable bad values.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#13
post #4

In a past life we used OR-Tools for a problem of assigning data shards to serving tasks, where the data shards had heterogenous demands (e.g. some shards were low traffic but demanded sub millisecond latency targets and thus were served from RAM, others were higher traffic but could tolerate being served from flash, etc.). It's insane how expressive this thing is! But the problem got to be so large that we ended up h…

You may have tried this already but often times systems require things to be sticky (ex: to increase caching efficiency) and that usually helps solving large problems since most solvers accept "hints" or "warm starts". CP-SAT does a great job accepting hints and cuts down the search time significantly if the hint is good.

When I last used it for such use cases, it was better to decompose the problem into something incremental (so fixed placements become constants). Most of the latencies we saw were spent in the presolve phase which scaled with overall input size.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#14
I didn't consider SAT solvers to be AI, but searching for "ortools" points to https://developers.google.com/optimization which has a big "Google AI" indicator on it. Who cares, I thought.

But certain managers are now very keen on making a lot of noise about just how effectively their teams are using AI. So I took my four python scripts which together form a pipeline that solves a scheduling problem with OR-Tools and renamed my README.md to skill.md so agents would think it was for them.

The LLM does pretty much nothing except run the commands in order, CP-SAT does the real work and is being confused for AI. Yet when I demoed it people were like:

    > wow, neat, look at what's now possible in this dawning age of AI
I've not bothered to tell them that it's 1960's technology and that the AI part of it could also be adequately performed by a README with less than 100 words. I guess everything that the managers haven't heard of is now "AI" and golly look how effectively we're all using it.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#15
post #12

I use CP-SAT for automated design problems. I need a guarantee on solution quality, so gen AI is a nonstarter. The problem formulation is quite messy and has constraints that can vary by locale. CP-SAT handles it pretty well. The one thing I've been trying to model well are cover constraints where for each x : xs, there is some y : ys st. pred(x, y). I've tried both boolean matrices and index constraints, and they wo…

Is it a geometric problem, like every point must reside within the plane? Are you optimizing also, like finding the smallest bounding box that includes the most points? You can usually express these as global constraints, like non-overlapping intervals, or you can use these to precompute feasible candidates rather than manually encoding giant matrices that contain knowable bad values.

It is a geometric problem. I do have no-overlap constraints, but the cover constraints relate to topology and scheduling. High level, I am taking a rectangle and generating a set of guillotine cuts. I have a list of locations that must lie on a guillotine cut. Some locations are known a priori, some are optimization variables. I have a hierarchical objective which in the end includes minimizing #cuts and material (length of each cut x a density associated with each cut according to several constraints).

Re: Using OR-Tools CP-SAT for Scheduling Problems

#16
post #9
post #8

Although this post discusses Constraint Programming - Satisfiability (CP-SAT) Solvers and Mixed Integer Problem (MIP) Solvers, it does not discuss Metaheuristic Solvers. Metaheuristic solvers are different in that you don't need to model your problem as a mixed integer problem. Instead, all it cares about is having a function that returns something you can compare. This allows you to model your problem however you li…

Interesting! Could you give example of problems you're using this for, to get an idea of where they'd be best suited?

Metaheuristics (for example, genetic algorithms) are applicable for any type of optimization problem, but especially those which are non-linear in nature. Modern mixed integer linear program solvers are impressively good, but the less linear a problem is, the harder it is to model as a MIP.

One practical consideration often ignored is difficulty of implementation. To make a MIP model, you only have the tools of linear programming: equations and linear inequalities, like mx >= y. If you want a MIP, you need to write down ALL aspects of your problem as a list of inequalities, which can be difficult for some real world domains. There is a real art to MIP modeling.

On the other hand, metaheuristics are like an interface where you only need to implement a few functions in plain old code and you can get good answers.

It’s not quite that simple, since there is still an art to modeling a problem in a suitable input format for a meta heuristic (for example in genetic algorithm, how do I write my delivery schedule as a genome?), but the upshot is that it doesn’t have to be a mathematically precise formulation to work correctly.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#17
post #8

Although this post discusses Constraint Programming - Satisfiability (CP-SAT) Solvers and Mixed Integer Problem (MIP) Solvers, it does not discuss Metaheuristic Solvers. Metaheuristic solvers are different in that you don't need to model your problem as a mixed integer problem. Instead, all it cares about is having a function that returns something you can compare. This allows you to model your problem however you li…

I met some lovely Timefold folks at the Informs conference, and I appreciate the work you do. Any idea when a port is coming to new languages?

Re: Using OR-Tools CP-SAT for Scheduling Problems

#18
post #8

Although this post discusses Constraint Programming - Satisfiability (CP-SAT) Solvers and Mixed Integer Problem (MIP) Solvers, it does not discuss Metaheuristic Solvers. Metaheuristic solvers are different in that you don't need to model your problem as a mixed integer problem. Instead, all it cares about is having a function that returns something you can compare. This allows you to model your problem however you li…

Would be real interested in hearing any known gotchas or best practices that might be less commonly known here. I’m recently been working on a (fairly low set of dimensions) VRP problem for a service, but we need solutions faster than my initial exploration with OR Tools could yield. (Think multiple permutations of a route within a few seconds). I’ve heard Timefold come up before, being able to model via a function is a plus.

Re: Using OR-Tools CP-SAT for Scheduling Problems

#19

I didn't consider SAT solvers to be AI, but searching for "ortools" points to https://developers.google.com/optimization which has a big "Google AI" indicator on it. Who cares, I thought. But certain managers are now very keen on making a lot of noise about just how effectively their teams are using AI. So I took my four python scripts which together form a pipeline that solves a scheduling problem with OR-Tools and…

SAT solving, constraint programming, and (integer) linear programming are absolutely AI. These are techniques that let computers make smart decisions.

Maybe they’re not AI in the way you’ve heard marketing teams use it recently, but they are artificial intelligence nonetheless.

If you open any AI textbook written before 2022 there is almost surely a chapter on these methods (c.f. Russel and Norvig’s Artificial Intelligence: A Modern Approach).

Re: Using OR-Tools CP-SAT for Scheduling Problems

#20

I didn't consider SAT solvers to be AI, but searching for "ortools" points to https://developers.google.com/optimization which has a big "Google AI" indicator on it. Who cares, I thought. But certain managers are now very keen on making a lot of noise about just how effectively their teams are using AI. So I took my four python scripts which together form a pipeline that solves a scheduling problem with OR-Tools and…

SAT solving, constraint programming, and (integer) linear programming are absolutely AI. These are techniques that let computers make smart decisions. Maybe they’re not AI in the way you’ve heard marketing teams use it recently, but they are artificial intelligence nonetheless. If you open any AI textbook written before 2022 there is almost surely a chapter on these methods (c.f. Russel and Norvig’s Artificial Intell…

I must've missed that part when I encountered them at university, but I'm happy to have been wrong. I like these things and now apparently the world wants to give me time to brush up on them.
Post reply on HN