Upload
hailey-trenholm
View
214
Download
1
Tags:
Embed Size (px)
Citation preview
A LGPL framework for combinatorial optimization &
problem solving
Renaud De Landtsheer
2
Content
• What are combinatorial problems?• Several approaches for solving combinatorial
problems• What is Asteroid• Roadmap
3
Combinatorial problem solving
• Given a problem: • A set of unknown, with discrete range
• hence, combinatorial problem• A set of constraints involving the unknowns• (An objective function to minimize / maximize)
• Find a value for each variable, such that• The values belong to the ranges of the
variables• Each constraint is enforced• (The objective is minimized / maximized)
4
Examples of combinatorial problems
• Scheduling problems eg: Job shop: • Set of tasks eg: 1k• With precedence constraints and ressource
usage• Minimize makespan
• Decision problems eg: Nqueens: • Given a chessboard of size N*N (eg: 1000)• Put N queens on it such that they do not
threaten each other• Routing problems eg: tsp+deadline
• Visit a set of places, with deadline constraints• Minimize overall distance
• Etc.
5
Approaches for solving combinatorial problems
• Exhaustive symbolic exploration • Constraint programming• MIP
• Local search -based• Constraint-based local search• Large neightboorhood search
• Other approaches• Column generation• Ant colony
Method should be tailored to requirements!
COMET, Kangaroo
(COMET, Scampi)
All CP engines
LocalSolver
GLPK, LPSolve…
Gecode, Jacop, CHOCO, COMET, Scampi
6
Relevant aspects to be considered
• Scalability• CBLS provides very good scalability, better
than CP• Optimality
• CBLS might be suboptimal; requires benchmarking
• Development cost• The more declarative is the framework, the
lower• Need for tuning
• MIP requires zero (but high modeling cost)• CP requires more, CBLS more than CP
• Specific requirements• Local search requires adequate search
heuristics
7
What bring these framework compared to a specific
development?• Declarativity
• Code your problem as it is defined, through standardized vocabulary, eg: constraints• allDiff(Array_of_variables)• a <= b+5
• Lower development cost• Thanks to declarativity, focus given to the fine
tuning, not to heavy development• Efficiency
• Standardized constraints are deeply optimized• Eg: Alldiff costs O(1) for each move in Asteroid
8
Local search
• Perform a descend in the solution space; repeatedly move from one solution to a better one
• Next solution identified via neighborhood exploration• Neighborhood = set of neighbors obtained by slightly
perturbing the solution (several possibilities)• Nqueens: moving a queen or swapping two queens• Scheduling: swapping two tasks• Routing: moving a task
9
Constraint-based local search
• Enables very fast evaluation of neightbors• Fastest than evaluating objective from scratch
• Additional mechanisms are provided to identify the most relevant neightbors without evaluating them• Eg: get the worse part of the problem
• Rich library of standardized formulas that can be used to encode a problem into the Asteroid framework
10
A standard Benchmark of Asteroid
1k 2k 3k 4k 5k 6k 7k 8k 9k 10k0
10
20
30
40
50
60
70
Run time of NQueen(swap) wrt number of queens
+ N² fitting
TtotalPolynomial (Ttotal)
run
tim
e [
secon
ds]
11
Logical Architecture of Asteroid
PropagationPropagation element, propagation structure
ComputationVariable, invariant, IntVar, IntSetVar
Library of invariantsPlus, minus, argMax, Inter, ArrayAccess, …
Constraint structureConstraint system, constraint
Constraint libraryeq, neq, ge, alldiff, atMost
SearchselectMax,…
stopwatch
12
Availability and Roadmap of Asteroid
• Asteroid is a research prototype for Wist3.0 project (Wallonie) • Developed entirely at CETIC• Aiming at prioritizing patients in oncology
services• Includes specific extensions for scheduling
problems
• Available free of charge under LGPL license• Bug correction, and some extensions are LGPL
• Written entirely in Scala
13
NQueens naïve: the initial blabla
object NQueens extends SearchEngine{ def main(args: Array[String]) {
val N:Int=40 val range:Range = Range(0,N) val MaxIT = 10000
println("NQueens(" + N + ")")
14
NQueens naïve : defining the problem
val m: Model = new Model val Queens:Array[IntVar] = new Array[IntVar](N) for (q <- range){Queens(q) = new IntVar(m, 0, N-1, q, "queen" + q)}
val c:ConstraintSystem = new ConstraintSystem(m)
c.post(AllDiff(for ( q <- range) yield (q plus Queens(q)).toIntVar)) c.post(AllDiff(for ( q <- range) yield (q minus Queens(q)).toIntVar))
c.close m.close
Plus and minus are infix expression for sum and minus invariants
AllDiff constructor does not require « new »(scala case class)
15
NQueens naïve : defining the search procedure
var it:Int =0
while((c.Violation.getValue() > 0) && (it < MaxIT)){
val (q1,q2):(Int,Int) = selectMin2(range, range, (q1:Int, q2:Int) => c.getSwapViol(Queens(q1), Queens(q2)), (q1:Int,q2:Int) => q1 < q2)
Queens(q1) :=: Queens(q2)
it += 1 println("it: " + it + " " + c.Violation + " (swapped "+ q1 + " and " + q2 + ")") }
16
NQueens naïve : printing & running
NQueens(40)it: 1 Violation:=38 (swapped 12 and 9)it: 2 Violation:=37 (swapped 8 and 39)…it: 33 Violation:=1 (swapped 10 and 14)it: 34 Violation:=0 (swapped 3 and 11)Violation:=0IntVars(queen0:=13,queen1:=17,queen2:=25,queen3:=11,queen4:=8,…
println(c.Violation) println(m.getSolution(true))}
17
Invariant library
• Logic• Acces on array of IntVar,
IntSetVar• Access on array of IntVar,
where index is IntSetVar• Sort• Filter, Cluster (indexes of
element whose value is…)• SelectLeSetQueue (for Tabu
search)• …
• MinMax• Min, Max (linear and Log
variants)• ArgMin, ArgMax
• Numeric• sum, prod, minus, div• Also on enumeration of
IntVar• abs
• Set• Cardinality• Inter, Union, Diff• Interval, MakeSet
• Look also in Computation Structure• Identity invariants• Events « TriggerOn »
18
Constraint Library
• Global• allDiff• atLeast• atMost (untested)
• Basic• Eq, Neq• G, GE• L, LE
19
Need more info
• Asteroid Website• Wiki
https://forge.pallavi.be/projects/asteroid/wiki• Svn https://svn.forge.pallavi.be/asteroid
• Scaladoc available• Also on the website
• Renaud De Landtsheer• [email protected]
20
References
Constraint-Based Local Searchby Pascal van Van Hentenryck, Laurent Michel