480 likes | 490 Views
This research paper discusses the integration of Constraint Programming (CP) and Operations Research (OR) techniques using ECLiPSe as a platform for hybrid solvers. It explores the benefits and applications of this hybrid approach in solving combinatorial optimization problems.
E N D
Hybrid Constraint Solving in ECLiPSe: Framework and Applications Farid AJILI, IC-Parc, Imperial College, London. March, 2002. (CP-AI-OR’02 School On Optimization, Le Croisic, France)
Agenda • Combinatorial Optimization • Integration of CP and OR techniques • CP and OR: what are they ? • Why both ? • ECLiPSe as a platform for hybrid solvers • Ingredients • Features • Probe Backtrack Search for CP-OR hybridization • Application: scheduling with piecewise linear optimization • Conclusion.
Combinatorial Optimization (1) • Intractable • No efficient general algorithm is known • Search for solution requires exponential time/space, e.g., • Problem size=10 solved in 1 nanosecond • Problem size=100 solved in 4 * age of the universe • Capture most of “real life” requirements • No solution approach is universally successful • Constraint Programming • Operations Research
Combinatorial Optimization (2) • Large scale • prohibitively expensive • Problem specificity • Every problem is unique • Very similar problems are actually different (sub-problem sizes, linking constraints,…) • Textbook solutions often won’t work • without modification/extensions • Problem structure embeds well-studied sub-problems • Scope for hybrid algorithms
Constraint Programming • CLP Program = Logic + Control • Logic => Modelling: • Expressive power (e.g., global constraints) • Clear and simple semantics • Control => Solving: • Fully exploit the structure of the constraints • Constraints communicate via variable domains • Inference based on constraint propagation/domain reduction • Search driven by problem-specific heuristics
CLP Modelling • Variables • Type • Domain • Constraints • N-ary relations • Built-ins or user-defined predicates • Model • = setup program X1{1..9} _ #> _ _ #\= _ X2{1..9} alldifferent([ _, _, _ ]) [X1,X2,X3,X4]::1..9, X1 #> X2, alldifferent([X2,X3,X4]), X1 #\= X4. X4{1..9} X3{1..9}
CLP Solving • CLP solving interleaves inference and search • The inference is supported by constraint propagation • Extract information from the constraint network • The network is simplified: inconsistent domain values are removed • Propagation is monotonic, sound and terminates • Search • Search disjunctive constraints through backtrackable decisions • Propagation might exclude some choices • “Guess” a decision using heuristics
A Solving Example (1) X{red,green} Search control \= Y{red,blue} \= \= Z{red,green,blue}
A Solving Example (2) X{red,green} Search control \= ? Y{red,blue} \= \= Z{red,green,blue}
A Solving Example (3) X{red} Search control \= Y{red,blue} \= \= Z{red,green,blue}
A Solving Example (4) X{red} Search control \= Y{blue} \= \= Z{green,blue}
A Solving Example (5) X{red,green} A solution Search control red \= Y{red,blue} \= blue \= Z{red,green,blue} green
The CLPView Constraint setup ( = Modeling ) Xi Cj • Generic CLP program: • solve(Vars) :- • constrain(Vars), • search(Vars). • constrain(Vars) :- • < Model > • search(Vars) :- • < Strategy > Propagation & Domain reduction Variables & Constraints Heuristics & Search control
Operational Research • Often associated to Mathematical Programming (MP) • Model and analyse decision problems • Assumption: optimization function and constraints are functions of the decision variables. • Restricted modelling power • Numeric domains • Equations/Inequalities • Integrality constraints • Solution methods take advantage of special structure of problems • Linear Programming (LP) (e.g., Simplex), • Branch and Bound (e.g., MIP) • Cutting Planes.
A MP Formulation Given |J| sites and |I| customers: Let cijbe the cost of satisfying demand i from the facility located at site j Let yij = 1 if demand of client iis served by facility j, 0 otherwise Let xj = 1 if a facility is opened at site j, 0 otherwise. LP Relaxation Non-linearity
CP more general constraints handle integers directly Favourable example: Variable Bounds: [X1,…,X100] :: 1..100 Previous Constraints: X1 < X2 , … , X98 < X99 Resulting Bounds: X1 :: 1..2, …, X99 :: 99..100 New Constraint: X1 >= 3 Result (1 step): failure! OR restricted class of constraints finds optimum without search Favourable example: Variable Bounds: [X1,X2] :: 1..100 New Constraints: X1 > X2, X2 > X1 Result (1 step): failure! CP versus OR
CP-MP Hybridization • Hybridization of traditional CP & MP • Successful approach for large-scale combinatorial optimization • Benefits are increasingly recognized • They have complementary characteristics • Pure CP • Powerful for satisfaction of combinatorial constraints • Weak on optimization because inference is based on local consistency • Pure MP • Special-purpose optimization for a special classes of problems (e.g. linear) • Weak on satisfaction of combinatorial constraints • Efficiency via CP-MP hybridization • Decomposition into well-structured sub-problems • Exploit problem structure and specificity
Ingredients for Hybridization • Expressive power of the “hybrid” language • Built-in primitives • Setup complex constraints before and during search • Flexible modelling • The hybrid algorithm consists of • backtrack search procedure, and • “support methods” which assist it • Accommodate co-operative solvers • Cooperate with the search as it progresses • Selection & Scope of appropriate methods to the sub-problems • Provide “glue” for heterogeneous solvers • Link sub-problems through variables and channels (“glue”) • Advanced control of solvers
The ECLiPSe Platform • ECLiPSe is a CLP environment • Development • ECRC, Munich IC-Parc AND Parc-Technologies Ltd • Growing academic user community • More than 400 academic licenses issued • Objectives of ECLiPSe • Development & Delivery of software solutions to real world problems • Solutions = Hybrids • Novel approach: support hybrid algorithms
Features for Hybridization • Constraint setup • Common conceptual model: one program for different solvers • Different solvers handle different constraint classes • Programmable mapping/relaxing into solver constraints • Synchronisation and integration • Search decisions are communicated to all solvers • Solvers are dealing with parts of the same problem • Information passing between solvers • How the information is integrated back to the search • Incremental prototyping • Incremental development of the solver • Incremental extension of the problem
Solver Cooperation in ECLiPSe • “Demons” and data-driven triggering • Fine grained waking conditions (narrowed bounds,...) • suspend(simplex_solve(Handle), 5, [X->min, X->max]) • Priority scheme • Cheap agents first, slow ones later • e.g., interval propagation before Simplex • Attributed variables • Bounds, Domain, Range • Tentative value (later) • Repair-based forward search • Search independently sub-problems • Support methods to aid the backtrack search Forward search methods
Repair library • Basic idea • Start with a “good” inconsistent “solution” • Increase consistency incrementally • Applications • Repair Problems • “good” inconsistent solution: the “previous” solution • Repair-Based Constraint Satisfaction • “good” inconsistent solution: the partially consistent soln. found by heuristics • Repair-Based Constraint Optimization • “good” inconsistent solution: a good soln. with respect to optimization function • Hybridization • “good” inconsistent solution: a good soln. produced by a forward search method
Basic concepts fd:3..6 repair:5 #>= #>= r_conflict fd:1..3 repair:3 X{ } • Variables can have “tentative values” X::1..9, X tent_set 5. X = X{fd:[1..9], repair:5} • Their changes are propagated [X,Y,Z] tent_set [1,1,1], S tent_is X+Y+Z,Y tent_set 5. S = S{repair:7} • Constraints can be monitored for violation [X,Y,Z] tent_set[1,2,3], X + Y #= Z r_conflict confset, %% X + Y #= Z satisfied X tent_set2, %% X + Y #= Z violated conflict_constraints(confset,Conf). %% Conf=[X+Y#=Z] Y{ }
Probe Backtrack Search • Partition problem into easy and hard part • Easy part: tractable • Hard part: remaining constraints • Solve the easy part using a specialised OR solver • Value suggestions (a probe) as a tentative assignment • Characteristics: • Optimally, satisfy the “easy sub-problem” • “Super-optimal” and partially consistent • Discrete values • Incrementally repair violations in the hard part • Make a choice: add an easy constraint (on backtracking, its negation) • Aim: reduce hard constraint violation in subsequent probes Cost Function EasyPart Hard Part
Algorithm Outline search:- define_problem(Vars), probe_tent_values(c,Vars), %% assigns tentative values repair_label(c, Vars). repair_label(CS,_):- conflict_constraints(CS, []), !. repair_label(CS, Vars): conflict_constraints(CS, [Constr|_]), fix_constr(Constr), probe_tent_values(CS, Vars), %% re-assigns tentative values to “better” values repair_label(CS, Vars).
A Toy Example (1) define_problem(Vars, rc, Handle, Trigger) :- Vars = [X1,X2,X3], fdplex:(Vars:: 1 .. 4), fdplex:(X2 - X3 #=<2), fdplex:(X2 #=< X1), fdplex:(-X2 + X3 #= 3), lp_demon_setup(min(X1 - X3),Cost,[],9,[trigger(simplex)],Handle), lp_get(Handle,vars,Vs), lp_get(Handle, solution, Solution), Vs tent_set Solution, sos2([X1,X2,X3]) r_conflict rc, Trigger = simplex. sos2(Vars):- Vars tent_get Vals, sos2_is_ok(Vals). No Integrality Constraints
A Toy Example (2) probe_tent_values(Handle,Trigger) :- schedule_suspension(Trigger), wake, lp_get(Handle,vars,Vars), lp_get(Handle,solution,Solution), Vars tent_set Solution. fix_constr(sos2([X1,X2,X3])) :- ( X3 = 0 ; X1 = 0 ). X3=0 X1=0
Input schedule (fixed times) s1 e1 e2 s2 s3 e3 No. of Resources Required 3 2 1 Time 3 2 1 s3 s2 s1
Output: retime activities S1 E1 E2 S2 S3 E3 No. of Resources Required 3 2 1 s1 s3 s2 New Requirements: 1) Only, two resources 2) Precedence constraints: S1 :: L … U 20 S1–E2 S2– E3=60 etc …
Some use-cases • Dynamic scheduling problems • Existing schedule is given • Constantly changing schedule environment • Use cases for re-scheduling • Cope with resource failures • Additional activities/requirements • Resource saving • Criteria • Minimal perturbation to existing schedule • Minimal schedule cost • Maximise schedule revenues • Starting point: industrial transportation application
Problem Interest Cost_i T0=Preferred Time • Piecewise Linear (PL) optimization • Captures most common objective criteria • Minimal perturbation • Tardiness • Earliness • Piecewise linearizations are often a good approximation • Hybrid algorithm for minimal perturbation • It significantly outperforms individual CP and CPLEX MIP solvers • [El-Sakkout, Wallace 2000] Time_i
Problem Input • Scheduling with piecewise linear (PL) optimisation • Input • Resources with their capacities, activities and their resource demands • For each activity, a PL constraint (Time_i, Cost_i) • Temporal constraints: • Let # be a relation in {=,,,,}, and U,V be temporal variables • Constraints are of the form: U # c or U # V+c where c • Assumption: time discreteness Cost_i Time_i
The Problem as a CSP • Constrained variables • Start/End time variables of activities • Boolean variables capturing whether an activity spans with an other activity start time • Cost-related variables • Constraint system • Resource utilisation rules • Resource demand is smaller than or equal to the available amount • Resource maintenance requirements • Temporal constraints • Bounding (e.g., time windows) • Distance/precedence relations • Objective function constraints • Cost definition • PL constraints • Cost bounds
Conceptual Model CP hard set Domain reduction Interval propagation Lookahead resource bound checking Heuristics Repair Relaxation+Probe Inference MP easy set Global cost Optimal assignment Discreteness
Probing Issues • Curves are non-convex (unlike Minimal Perturbation) • Pure Linear Programming is not enough • Which part handles the non-convexity of the piecewise linearity ? • Easy part contains a linear relaxation of the PL constraints • Linear Programming is enough • More search to fix the PL violations • Easy part contains the PL constraints • Need to use Mixed Integer Programming (MIP) • Different options for the probers • The -formulation (MIP) • The -formulation (MIP) • Linear relaxation (LP) MIP/LP problem Probing CP search
The Hybrid Algorithm • Probing phase: • Purpose: get a tentative temporal assignment (“probe”) • Scope: minimize Cost subject to Temporal & PL constraints • Structure: the integrality of the temporal variables is guaranteed • Resource feasibility phase: • Monitor resource constraints for violation • Probe guides the search towards “conflict regions” • Repair incrementally the violations • Select a resource violation (e.g., the maximum infeasibility, ..) • “Guess” a distance constraint reducing the contention • The constraint should preserve the tractability of the probing sub-problem X <Y XY
The role of the probe Tentative Variables Y{1..4}3 Conflict Region of Violated Constraints Fixed Variables X{4}4 • High quality • Focus the search
Outline of the Algorithm 1. Apply propagation to all the constraints consistent 2. Temporal && PL Optimisation Apply the Prober to the easy part optimum integer values none: Exit with success 3. Determine the set of violated constraints 4. Select a violated constraint 5. Feasibility (Backtrackable decision) Impose a new temporal ordering constraint C to reduce violations
Some Notes • Discreteness of the the temporal variables • Make easier the integration with FD reasoning • Caution: no cost bound in the MIP formulation • Inference via probing • Propagation based on the “Reduced costs” • Fix variables to their lower/upper bounds if them will not improve the cost • Close cooperation is more effective • The probing sub-problem is dynamically re-shaped during search • Tighten individual PL constraints [Refalo, 99]
The -formulation Cost Time For each (Time, Cost) • Tightening the probing sub-problem • Variable Fixing [Refalo, 99] • Infer further “cuts” on the s
The -formulation Cost Time For each (Time, Cost) • Tightening the probing sub-problem: • Similarly, some s can be fixed [Refalo, 99] • Derive further “cuts” on them
Linear Relaxation T • Model (Time, Cost) by its convex hull • Split the domain of Time and branch • Incrementally updated. Time T 1+TTime Cost Time
The Repair Strategy |Res| 3 2 2 1 Time • Two types of violation • Resource violations • PL violations • Repair priority • Resource violations • PL violations • Advantage • Favours resource feasibility • Initially ignore accuracy of costs 1
Evaluation & Discussion • Evaluation on randomly generated tests • Problem tightness • Amount of resource saving • PL optimisation: “distance” from the convex case • The strength of the pruning in H(MIP) • H(relax) outperforms H(-prober): • “First, repair resource violations” versus “First, repair PL violations” • Cheap probing versus probe quality • Ongoing work withother applications • Networking area
Conclusion • Even when problem precludes OR, hybridization is beneficial! • ECLiPSe is an environment for integration of • Models • Solvers • More hybrid schemes are available • Bender’s Decomposition • Column Generation • CP mixed with Langrangian Relaxation • CP combined with Local Search • Finite Domains & Real Interval Propagation • and 44 solvers/libraries.