I'm looking into rewriting Storm's resource scheduler using
core.logic. I want to be able to say constraints like:
1. Topology A's slots should be <= 10 and as close to 10 as possible
(minimize the delta between assigned slots and 10)
2. All topologies should use less than 200 CPU's and less than 600 GB
of memory
3. Topology B should run at most 2 workers on each host
4. Each worker for topology C should run at most one task for
component X and one task for component Y
5. Should minimize the amount of reassignment to running topologies in
order to satisfy constraints
6. Should only be allowed to reassign workers for an individual
topology whose individual constraints are satisfied once every 10
minutes
And so on. I have two questions:
1. How good is core.logic at culling the search space using arithmetic
logic? For example, if it knows that x + y <= 5, x>=0, and y>=0, it
should never bother with areas of the search space where x or y are
>=5.
2. Can core.logic do things like search the space for which my
evaulation criteria are minimized? Or is what we're trying to do a
better fit for different techniques like linear programming?
Cool, thanks for the quick response. We'll be looking into this pretty
soon. I ultimately want the logic engine itself being exposed to users
so they can add their own company-specific constraints to resource
scheduling – which will be totally badass. If you're interested in
tracking this, I opened up an issue on Storm: https://github.com/nathanmarz/storm/issues/383
Nathan:
I don't know core.logic's capabilities, and I haven't looked at the kinds of constraints you describe in enough detail to say for sure, but my initial reaction is that linear/integer programming might be a better fit.
It sounds like something that would benefit from good constraint
propagation. If I remember correctly, core.logic only support
propagating equality/inequality constraints which can be pretty slow
for exploring large domains. Something like gecode
(http://www.gecode.org) might be a better fit if you want to use large
integer domains.
Where core.logic lvars can only be assigned or fresh, gecode
explicitly represents the domain of each variable and can efficiently
propagate constraints across them. In your example, x and y would both
have domain [0,5]. If you added the constraint x >=3, after
propagation you would have x: [3,5] y:[0,2]
Gecode also has support for custom search strategies which would allow
writing heuristics for minimisation. I'm not sure if gecode would ever
be as fast as a linear programming solution but it's certainly more
flexible.