fslaborg / flips

Fsharp LInear Programming System
https://flipslibrary.com/#/
MIT License
252 stars 32 forks source link

Add support for constraint programming #53

Closed Shmew closed 3 years ago

Shmew commented 4 years ago

I've used the CP-SAT Solver to optimize job scheduling (thousands of jobs that run daily) that takes into account specific dependencies, resources, and time constraints. It was a massive pain to understand how to use the Google.OrTools.Sat namespace as their documentation is quite sparse.

It would be nice to have it supported with this library. In particular it was a nightmare converting this into something usable.

matthewcrews commented 4 years ago

@Shmew Could you provide me some example problems/formulations with solutions that I can use for a test bed? I am wanting to understand the problem space to make sure that we get the "ergonomics" of using the library correct.

I am thinking that this will likely involve some new types to ensure that people do not try to use an incorrect type of model/solver combination.

Also, if you have any recommended literature/textbooks on the subject, I would love to hear about it. I have not worked in this domain much so I would like to get up to speed. Thanks for the help!

Shmew commented 4 years ago

Here's an example (that's probably poorly done) gist. This was to find the optimal schedule given the constraints defined in the json file for the job shop problem. I don't have much in terms of recommendations, I pretty much fumbled through this until I got something that I believed to be working.

Honestly it was a pain to get this far, as their documentation in many parts was python only, and pretty sparse. I had to trawl through the repo issues/google group/source code to figure out how to do it all, especially in a non-imperative style.

matthewcrews commented 4 years ago

@Shmew I've been reading up on this and it appears to be a different enough domain that I think I would rather create a different library for that domain. My goal with this library was to create something simple specifically for LP/MIP.

It's sounds like an interesting problem though! I am going to need to do some more reading up and look at some real world problems to get my head around it.

I am also actively trying to learn more about Category and Type Theory in order to come up with better abstractions. There are some features coming in F# 5.0 which will make all of this easier.

This library was a great learning experience though and lays a foundation for doing this work. I have learned a ton from this experience and making something equivalent for CP-SAT Solver will likely be much faster.

NatElkins commented 3 years ago

Just want to chime in, I also have this use case. I'm probably going to take a crack at using the Google OR library directly for a problem that is very similar to this one: https://developers.google.com/optimization/scheduling/employee_scheduling

There's a good .NET example here: https://github.com/google/or-tools/blob/master/examples/dotnet/ShiftSchedulingSat.cs

matthewcrews commented 3 years ago

I will be addressing this request with the Coffy Library. I will be adding this discussion to that library.

COFFY: Constraint Optimization For Fsharp Yay