Download presentation

Presentation is loading. Please wait.

Published byDominick Banton Modified about 1 year ago

1
A Master-Slave Architecture to Integrate Sets and Finite Domains in Java F. Bergenti E. Panegai G. Rossi Università degli Studi di Parma Bari, 26-27 Giugno 2006 Convegno Italiano di Logica Computazionale

2
CILC 06 – Bari, 26/27 Giugno 2006 2 Outline of the talk Aims: Implement and validate the integration of JSetL (a set solver) and JFD (a finite domains solver) ; Find out a generic architecture approach for a cooperation between constraint solvers ; The Master-Slave architecture; Case study: JSetL+JFD; Conclusions and future work.

3
CILC 06 – Bari, 26/27 Giugno 2006 3 Introduction Solvers are normally implemented on the basis of more or less explicit tradeoffs between: Capabilities: the kinds of constraints they manage and under which assumptions; and Performances: the adopted strategies, heuristics and optimizations. Often single solvers cannot be used on hybrid problems. Idea: Combine several constraint solving techniques to solve problems that none of the single solvers can handle alone. CILC 06 – Bari, 26/27 Giugno 2006

4
4 A common architectural outline can be found in many frameworks and architectures that explore the cooperative integration of constraint solvers: A top level of meta-resolution (namely a meta- solver); A set of constraint solvers; and An interface between the meta-solver and the object-level solvers. Introduction CILC 06 – Bari, 26/27 Giugno 2006 Meta-solver Solver 1 Solver 2 Solver n Interface

5
CILC 06 – Bari, 26/27 Giugno 2006 5 We always need a layer of meta-resolution? Often this layer implies implementation efforts to realize functionalities already present in the solvers. The master-slave (M-S) approach: No meta-solver One of the solvers is opportunely selected and promoted to the role of master. Introduction Meta-solver Solver 1 Solver 2 Solver n Interface Solver 2 Solver n Solver 1 Interface

6
CILC 06 – Bari, 26/27 Giugno 2006 6 The case study integrate two Java solvers, namely JSetL and JFD, into an added-value Java constraint solver capable of exploiting: The full expressive power of JSetL, with its inherent flexibility and generality; and The efficiency of JFD in treating finite integer domains variables. Constraint solving algorithms are basically the same exploited in CLP(Set+FD). Moving from a logic programming framework, to an OO programming context (Java) causes some implementation decisions to become more evident. Introduction

7
CILC 06 – Bari, 26/27 Giugno 2006 7 M-S Constraint Solving The general architecture: Each solver is responsible for a predefined set of constraints and is equipped with a private constraint store (conjunction of atomic constraints). The main task of each solver is to try to reduce any conjunction of atomic constraints to a simplified (irreducible) form. One solver is selected as Master solver, all the others are Slaves (Slaves are black boxes). The master is in charge of distributing tasks to, and gathering results from, the slaves. The constraint distribution policy is based on a fixed a-priori mapping.

8
CILC 06 – Bari, 26/27 Giugno 2006 8 M-S Constraint Solving : Selection of Master Good selection of the master: 1. The master should provide a constraint language that subsumes the union of the languages of all slaves; 2. The performances: slaves should perform better than the master in their reference domains; 3. The support for constraint programming abstractions, e.g., logical variables and nondeterminism; 4. The possibility of extending the selected solver to integrate master-specific procedures (e.g., constraint dispatching, result processing etc.); and 5. The public functionalities provided to programmers.

9
CILC 06 – Bari, 26/27 Giugno 2006 9 At first stage the master needs to communicate constraints. Allocation of an atomic constraint C=op(t 1,...,t n ): (MASTER) If C is a constraint of the master and S=Ø, then the master solves it; (SLAVE) If C is not a constraint of the master and S Ø, then C is posted to all slaves in S; (BOTH) If C is a constraint of the master and S Ø, then the master posts C to all slaves in S and then solves it; or (UNKNOWN) If C is not a constraint of the master and S=Ø, the allocation fails, i.e., the constraint is unknown. M-S Constraint Solving : Communication

10
CILC 06 – Bari, 26/27 Giugno 2006 10 Communication second stage: Interface that slave solvers provide: add(C) where C is a slave constraint to be added to the constraint store of the slave; get_constraints() that returns the conjunction of constraints that are present in the store of the slave; solve(B) where B is a value from an enumerative type used to specify which solving process is requested. M-S Constraint Solving : Communication

11
CILC 06 – Bari, 26/27 Giugno 2006 11 Communication third stage: we need other glue functions for translate and filter constraints: master_to_slave(Slave,C) translates a master constraint C to the corresponding slave constraint; slave_to_master(Slave,D) translates a slave constraint D to the corresponding master constraint; which_type(C) that allows C to be classified as belonging to one of the four types of constraints MASTER, SLAVE, BOTH and UNKNOWN; and which_slave(C) that maps C to a possibly empty set of slaves that can handle it. M-S Constraint Solving : Communication

12
CILC 06 – Bari, 26/27 Giugno 2006 12 The master's procedure for constraint solving: procedure master_solve(Constraint Store) repeat reset(Store); step(Store) until is_final_form(Store) end procedure; Actions are repeated until the solving process terminates successfully or until it fails. The process terminates successfully when no further constraint can be reduced or allocated to slaves and when all results are gathered from the constraint stores of slaves. The process fails when the master, or any slave, detects an inconsistency and no further nondeterministic choices are left open. General Constraint Solving Procedures

13
CILC 06 – Bari, 26/27 Giugno 2006 13 procedure step (Constraint Store) C = extract(Store);// Constraint C Selected_Slaves = Ø; while C true do T = which_type(C); Slaves = which_slave(C);// Set Slaves Selected_Slaves = Selected_Slaves υ Slaves;// Set Selected_Slaves if T == SLAV E or T == BOTH then for all Slave Slaves do Slave.add(master_to_slave(Slave, C)) end for if T == BOTH or T == MASTER then handle_constraint(Store,C) C = extract(Store); end while; for all Slave Selected_Slaves do Slave.solve(REDUCE); slave_try_next(Slave, Store) end for; end procedure; General Constraint Solving Procedures

14
CILC 06 – Bari, 26/27 Giugno 2006 14 The master and the slaves solvers can be sources of nondeterminism. The slaves interface modules further provide the following methods: next_solution() to explore the next nondeterministic alternative that a previous call to solve might have left open. save() that returns a snapshot of the current state of computation of a slave; and restore() that restores a previously saved state. Nondeterminism Management

15
CILC 06 – Bari, 26/27 Giugno 2006 15 General Constraint Solving Procedures Procedure used to explore nondeterministic choices left open by slaves: procedure slave_try_next(Solver Slave, Constraint Store) Constraint D; either D = slave_to_master(Slave, Slave.get_constraints()); if D == false then fail else insert(Store,D); end if; orelse // try next nondeterministic alternative Slave.next_solution(); slave_try_next(Slave, Store) end either end procedure;

16
CILC 06 – Bari, 26/27 Giugno 2006 16 JSetL is a library that endows Java to support general purpose declarative programming. In particular, JSetL provides: logical variables, unification, list and set data structures, constraint solving, and nondeterminism. JFD is a library that provides constraint solving techniques for variables with finite domains. Case Study: JSetL+JFD

17
CILC 06 – Bari, 26/27 Giugno 2006 17 Case Study: JSetL+JFD procedure step (Constraint Store)... // initialization while C true do T = which_type(C); Slaves = which_slave(C);// Set Slaves Selected_Slaves = Selected_Slaves υ Slaves;// Set Selected_Slaves if T == SLAV E or T == BOTH then for all Slave Slaves do Slave.add(master_to_slave(Slave, C)) end for if T == BOTH or T == MASTER then handle_constraint(Store,C) C = extract(Store); end while; for all Slave Selected_Slaves do Slave.solve(LABEL_ALL); slave_try_next(Slave, Store) end for; end procedure;

18
CILC 06 – Bari, 26/27 Giugno 2006 18 The handle_constraint procedure of JSetL+JFD: procedure handle_constraint(Constraint Store, Constraint C) if C == op (o1,o2) then member(Store, C) else if C == op = (o1,o2) then equals(Store, C) else if... then else if C == next then slave_try_next(Store, C) // Unroll nondeterministic choice end if end procedure Case Study: JSetL+JFD

19
CILC 06 – Bari, 26/27 Giugno 2006 19 The procedure used to explore nondeterministic choices left open by slaves: procedure slave_try_next(Constraint Store, Constraint C) Constraint D; if C.get_alternative() = 0 then add_choice_point(next); // save computation state D = slave_to_master(jfd, jfd.get constraints()); if D = false then fail else insert(Store,D) end if else jfd.next solution();. try next nondeterministic alternative insert(Store, next) end if end procedure Case Study: JSetL+JFD

20
CILC 06 – Bari, 26/27 Giugno 2006 20 Case Study: JSetL+JFD Nondeterminism is confined to constraint solving: procedure member(Constraint Store, Constraint C) if C = op (o1,Ø) then fail else if C = op (o1,X) then insert(Store, op = (X, {o1 |N})) else if C = op (o1, {o2 | s}) then if C.get_alternative() = 0 then add_choice_point(C); // Save nondeterministic choice insert(Store, op=(o1, o2)) else insert(Store, op2(o1, s)) end if else if... then end if end procedure

21
CILC 06 – Bari, 26/27 Giugno 2006 21 Extend constraints management and functionalities of JSetL+JFD. Tests on solving process and labeling. Tests with more slaves (i.e Solver for multisets). Application on Configuration Problems. Download at: http://www.math.unipr.it/~gianfr/JSetL/ Conclusions and Future Work

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google