Optimising Quantified Expressions Optimising Quantified Expressions in Constraint Models Ian P. Gent, Ian Miguel and Andrea Rendl University of St Andrews, UK AIT Austrian Institute of Technology, Austria September 2010 Workshop on Modelling and Reformulation
Optimising Quantified Expressions Context of this Work Quantified expressions in solver-independent constraint modelling languages
Optimising Quantified Expressions Context of this Work Quantified expressions in solver-independent constraint modelling languages Example: forall i,j:int(1..n) . (i � = j) ⇒ (q[i]-i � = q[j]-j)
Optimising Quantified Expressions Context of this Work Quantified expressions in solver-independent constraint modelling languages Example: forall i,j:int(1..n) . (i � = j) ⇒ (q[i]-i � = q[j]-j) powerful means to compactly represent a set of expressions
Optimising Quantified Expressions Context of this Work Quantified expressions in solver-independent constraint modelling languages Example: forall i,j:int(1..n) . (i � = j) ⇒ (q[i]-i � = q[j]-j) powerful means to compactly represent a set of expressions same structure in all constraint modelling languages
Optimising Quantified Expressions Context of this Work Quantified expressions in solver-independent constraint modelling languages Example: forall i,j:int(1..n) . (i � = j) ⇒ (q[i]-i � = q[j]-j) powerful means to compactly represent a set of expressions same structure in all constraint modelling languages restriction : no decision variables in i 1 , . . . , i m and int(lb..ub)
Optimising Quantified Expressions Goal and Contributions Our Observation : quantified expressions can contain redundancies , often when formulated by novices
Optimising Quantified Expressions Goal and Contributions Our Observation : quantified expressions can contain redundancies , often when formulated by novices Our Goal : automatically improve poorly formulated quantified expressions
Optimising Quantified Expressions Goal and Contributions Our Observation : quantified expressions can contain redundancies , often when formulated by novices Our Goal : automatically improve poorly formulated quantified expressions Our Contributions : we consider 2 kinds of redundancies
Optimising Quantified Expressions Goal and Contributions Our Observation : quantified expressions can contain redundancies , often when formulated by novices Our Goal : automatically improve poorly formulated quantified expressions Our Contributions : we consider 2 kinds of redundancies we propose means to detect and address those redundancies
Optimising Quantified Expressions Loop-invariant Expressions 1 Loop-invariant Expressions 2 Weak Guards 3 Summary
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Idea : analyse equivalent representations of quantified expressions
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Idea : analyse equivalent representations of quantified expressions Example: ( x = 0 ) ⇒ ∀ i ∈ D . ( x [ i ] = i )
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Idea : analyse equivalent representations of quantified expressions Example: ( x = 0 ) ⇒ ∀ i ∈ D . ( x [ i ] = i ) ≡ ∀ i ∈ D . ( x = 0 ) ⇒ ( x [ i ] = i )
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Idea : analyse equivalent representations of quantified expressions Example: ( x = 0 ) ⇒ ∀ i ∈ D . ( x [ i ] = i ) ≡ ∀ i ∈ D . ( x = 0 ) ⇒ ( x [ i ] = i ) we call ‘ ( x = 0 ) ’ loop-invariant
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Idea : analyse equivalent representations of quantified expressions Example: ( x = 0 ) ⇒ ∀ i ∈ D . ( x [ i ] = i ) ≡ ∀ i ∈ D . ( x = 0 ) ⇒ ( x [ i ] = i ) we call ‘ ( x = 0 ) ’ loop-invariant Question: which representation is better?
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Many different cases.... 1 A ∧∀ I E I ≡ ∀ I A ∧ E I
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Many different cases.... 1 A ∧∀ I E I ≡ ∀ I A ∧ E I 2 A ∨∃ I E I ≡ ∃ I A ∨ E I 3 m A + � ≡ � I A + E I where m = | I | I E I 4 A ∨ ( ∀ I E I )) ≡ ∀ I A ∨ E I 5 etc
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Many different cases.... 1 A ∧∀ I E I ≡ ∀ I A ∧ E I 2 A ∨∃ I E I ≡ ∃ I A ∨ E I 3 m A + � ≡ � I A + E I where m = | I | I E I 4 A ∨ ( ∀ I E I )) ≡ ∀ I A ∨ E I 5 etc Intuitively, we expect the outside-representation to be better...
Optimising Quantified Expressions Loop-invariant Expressions Loop-invariant Expressions Many different cases.... 1 A ∧∀ I E I ≡ ∀ I A ∧ E I 2 A ∨∃ I E I ≡ ∃ I A ∨ E I 3 m A + � ≡ � I A + E I where m = | I | I E I 4 A ∨ ( ∀ I E I )) ≡ ∀ I A ∨ E I 5 etc Intuitively, we expect the outside-representation to be better... is this true for all cases?
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations We compare representations at solver level (flat representation)
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations We compare representations at solver level (flat representation) We assume the solver provides: (reifyable) n -ary conjunction ( ∀ ) (reifyable) n -ary disjunction ( ∃ ) n -ary sum ( � )
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations We compare representations at solver level (flat representation) We assume the solver provides: (reifyable) n -ary conjunction ( ∀ ) (reifyable) n -ary disjunction ( ∃ ) n -ary sum ( � ) Let’s look at one case (see paper for other cases): A ⇒ ( ∀ I E I ) ≡ ∀ I A ⇒ E I
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation Outside-Representation Original ( ∀ I A ⇒ E I ) A ⇒ ( ∀ I E I )
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation Outside-Representation Original ( ∀ I A ⇒ E I ) A ⇒ ( ∀ I E I ) Unrolled ( A ⇒ E 1 ) ∧ A ⇒ ( E 1 ∧ · · · ∧ E k ) . . . ( A ⇒ E k )
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation Outside-Representation Original ( ∀ I A ⇒ E I ) A ⇒ ( ∀ I E I ) Unrolled ( A ⇒ E 1 ) ∧ A ⇒ ( E 1 ∧ · · · ∧ E k ) . . . ( A ⇒ E k ) Flat a ⇒ e 1 aux ⇔ ( e 1 ∧ · · · ∧ e k ) (unnested) . . . a ⇒ aux a ⇒ e k
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation Outside-Representation Original ( ∀ I A ⇒ E I ) A ⇒ ( ∀ I E I ) Unrolled ( A ⇒ E 1 ) ∧ A ⇒ ( E 1 ∧ · · · ∧ E k ) . . . ( A ⇒ E k ) Flat a ⇒ e 1 aux ⇔ ( e 1 ∧ · · · ∧ e k ) (unnested) . . . a ⇒ aux a ⇒ e k 0 auxiliary variables 1 auxiliary variable k constraints 2 constraints
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation : more constraints (increasing with k ), no additional variables
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation : more constraints (increasing with k ), no additional variables Outside-Representation : only two constraints but 1 additional variable
Optimising Quantified Expressions Loop-invariant Expressions Comparing Representations Inside-Representation : more constraints (increasing with k ), no additional variables Outside-Representation : only two constraints but 1 additional variable Let’s compare the representations in an example!
Optimising Quantified Expressions Loop-invariant Expressions Example: Peaceful Army of Queens Place two equally-sized armies of queens on a chess board such that they do not attack another, maximising the army size
Optimising Quantified Expressions Loop-invariant Expressions Peaceful Army of Queens: Outside Representation Non-attacking Constraints in model based on Smith et al (2004): forall fields(i,j) on the chess board.
Optimising Quantified Expressions Loop-invariant Expressions Peaceful Army of Queens: Outside Representation Non-attacking Constraints in model based on Smith et al (2004): forall fields(i,j) on the chess board. white queen at field(i,j) ⇒
Optimising Quantified Expressions Loop-invariant Expressions Peaceful Army of Queens: Outside Representation Non-attacking Constraints in model based on Smith et al (2004): forall fields(i,j) on the chess board. white queen at field(i,j) ⇒ forall k . no black queen at field(i,k) (same column)
Optimising Quantified Expressions Loop-invariant Expressions Peaceful Army of Queens: Outside Representation Non-attacking Constraints in model based on Smith et al (2004): forall fields(i,j) on the chess board. white queen at field(i,j) ⇒ forall k . no black queen at field(i,k) (same column) ∧ no black queen at field(k,j) (same row)
Recommend
More recommend