• No se han encontrado resultados

METODOLOGÍA DE LA INVESTIGACIÓN

O: nivel de comprensión lectora

4.5. Discusión de resultados

Peg Solitaire (see CSPLib 37 [36]) is played on a board with a number of holes. In the English version of the game, the board is in the shape of a cross with 33 holes. Pegs are arranged on the board so that at least one hole remains. Moves are draughts/checkers-like and are horizontal or vertical. There are several variations of Peg Solitaire. We focus on the classicreversalgame in which an initial state with just one peg missing is transformed into a state with a single peg remaining in the same location as the initial hole (Fig. 7.4 shows a sample instance).

Constraint Models of Peg Solitaire

The action variablesmovess represent the particular move (transition from one cell to an-

Figure 7.4: Peg Solitaire start (left) and goal (right) board states: black dots mark pegs and white dots mark empty cells.

boards

i represent the state of celliat stepsas a Boolean value: if true, the cell is occupied

by a peg, if false it is empty. It takes 31 steps to remove 31 pegs.

Based upon these variables, we consider two model variants. The first is action-centric (Fig. 7.5): for a given move it describes the cells that change and those that stay the same (1), which corresponds to the basic model representation from the Background section. The second isstate-centric (Fig. 7.6): for each cell, it describes the moves that cause it to change state and those that leave it unaffected (2), which corresponds to the successor-state model. Both models share initial/goal constraints and the implied constraint.

Common Subexpressions in Peg Solitaire

The representation of a state in Peg Solitaire is more complex than for Sokoban, consisting as it does of 33 Boolean variables per step. Since each move affects three cells on the board (and leaves 30 unchanged), there is considerable overlap: The removal of a peg from a particular cell can result from up to 8 different moves, i.e. it is a shared effect. Likewise, the reverse action, placing a peg into a hole, is shared among up to 4 different moves. The biggest overlap occurs in the frame axioms, as a particular cell is left unchanged by up to 72 different actions. It is from this overlap that the common subexpressions in the frame/effect/precondition constraints stem.

Action-centric Model In the action-centric model, we detect common subexpressions

that result from effect constraints, as illustrated in (case A) in Section 3. For instance, moves ‘36’ and ‘37’ both remove a peg from the centre hole(17), expressed in the legal transition constraint (4) in Figure 7.5), so both actions share effects:

(movess= 36)(boards

17>boards17+1∧...)

(movess= 37)(boards

17>boards17+1∧...)

Specifically, a standard instance of the action-centric model has 3,999 common subexpres- sions, which when eliminated, save 75,857 auxiliary variables (i.e. reducing the number of auxiliary variables from 80,104 to 5,425).

l e t t i n g moveNb : $ ( f i e l d 1 , f i e l d 2 ) −−−> move matrix indexed by [i n t( 1 . . 3 3 ) ,i n t( 1 . . 3 3 ) ] of i n t( 0 . . 7 6 ) be [ . . . ] l e t t i n g fieldNb : $ ( move ,{1 , 2 , 3}) −−−> f i e l d matrix indexed by [i n t( 1 . . 7 6 ) ,i n t( 1 . . 3 ) ] of i n t( 1 . . 3 3 ) be [ . . . ] l e t t i n g nbSteps be 31 l e t t i n g fields be 33

given startField : i n t( 1 . .fields)

l e t t i n g STEPS be domain i n t( 0 . .nbSteps)

l e t t i n g FIELDS be domain i n t( 1 . .fields)

f i n d moves: matrix indexed by [i n t( 0 . .nbSteps1)] of i n t( 1 . . 7 6 )

f i n d board: matrix indexed by [STEPS, FIELDS] of bool

such t h a t

$ ( 1 ) i n i t i a l s t a t e : a l l f i e l d s a r e o c c u p i e d b u t t h e one i n t h e c e n t r e f o r a l l i : FIELDS .

(i != startField) => (board[ 0 ,i] = true) ,

board[ 0 ,startField] = f a l s e ,

$ ( 2 ) g o a l s t a t e : o n l y t h e i n i t i a l f i e l d i s o c c u p i e d f o r a l l i : FIELDS .

(i != startField) => (board[nbSteps,i] = f a l s e) ,

board[nbSteps,startField] = true,

$ ( 3 ) i n e v e r y s t e p t h e number o f pegs d e c r e a s e s by 1 f o r a l l step : STEPS .

noFieldsstep1 = (sum i : FIELDS . board[step,i] ) ,

$ ( 4 ) l e g a l t r a n s i t i o n s f o r a l l step : i n t( 0 . .nbSteps1) . f o r a l l f1,f2 : FIELDS . $ i f t h e r e e x i s t s a l e g a l move from f 1 t o f 2 ( (moveNb[f1,f2] != 0 ) /\ (f1 != f2) ) => $ and we s e l e c t t h a t move , t h e f o l l o w i n g h o l d s . .

( (moves[step] = moveNb[f1,f2] ) <=> $ e f f e c t and p r e c o n d i t i o n

( (board[step, f1] > board[step+1 ,f1] ) /\

(board[step,fieldNb[moveNb[f1,f2] , 2 ] ] > board[step+1 , fieldNb[moveNb[f1,f2] , 2 ] ] ) /\

(board[step, f2] < board[step+1 , f2] ) /\

$ frame axiom

f o r a l l field : FIELDS . ( (field != f1) /\

(field != fieldNb[moveNb[f1,f2] , 2 ] ) /\

(field != f2) ) =>

(board[step,field] = board[step+1 ,field] ) )

)

Figure 7.5: Peg Solitaire Action Modelin ESSENCE!

State-centric Model In the state-centric model, common subexpressions arise in the

successor-state constraints, illustrated as (case D) in Section 3. As an example, consider the constraints (5) and (6) in Fig. 7.6, describing the possible actions when a peg is inserted(5)

l e t t i n g moveNb : $ ( f i e l d 1 , f i e l d 2 ) −−−> move

matrix indexed by [i n t( 1 . . 3 3 ) ,i n t( 1 . . 3 3 ) ] of i n t( 0 . . 7 6 ) be [ . . . ]

l e t t i n g fieldNb : $ ( move ,{1 , 2 , 3}) −−−> f i e l d

matrix indexed by [i n t( 1 . . 7 6 ) ,i n t( 1 . . 3 ) ] of i n t( 1 . . 3 3 ) be [ . . . ]

$ same c o n s t a n t s and p a r a m e t e r s a s i n A c t i o n Model

f i n d moves: matrix indexed by [i n t( 0 . .nbSteps1)] of i n t( 1 . . 7 6 )

f i n d board: matrix indexed by [STEPS, FIELDS] of bool

such t h a t $ same c o n s t r a i n t s (1)(3) a s i n A c t i o n Model $ ( 4 ) Frame Axioms : f o r a l l step : i n t( 0 . .noSteps1) . f o r a l l f : FIELDS . $ i f f i e l d f s t a y s t h e same

(bState[step, f] = bState[step+1 ,f] ) <=>

$ t h e n no move has been s e l e c t e d t h a t i n c l u d e s f

(f o r a l l f1 : FIELDS .

( (moves[step] != moveNb[f,f1] ) /\

(moves[step] != moveNb[f1,f] ) /\

f o r a l l f2 : FIELDS .

( ( ( moveNb[f1,f2] != 0 ) =>

( (f = fieldNb[moveNb[f1,f2] , 2 ] ) =>

(moves[step] != moveNb[f1,f2] ) ) ) /\

( ( moveNb[f2,f1] != 0 ) =>

( (f = fieldNb[moveNb[f2,f1] , 2 ] ) =>

(moves[step] != moveNb[f2,f1] ) ) ) ) ) ) , $ ( 5 ) Moving a peg t o f i e l d f f o r a l l step : i n t( 0 . .noSteps1) . f o r a l l f : FIELDS . $ 0−> 1

(bState[step,f] < bState[step+1 ,f] ) <=> e x i s t s f1 : FIELDS .

(moveNb[f1,f] != 0 ) /\

(moves[step] = moveNb[f1,f] ) ,

$ ( 6 ) Removing a peg from f i e l d f f o r a l l step : i n t( 0 . .noSteps1) .

f o r a l l f : FIELDS . $ 1−> 0

(bState[step,f] > bState[step+1 ,f] ) <=>

(e x i s t s f1 : FIELDS .

$ middle peg

(e x i s t s f2 : FIELDS .

( moveNb[f1,f2] != 0 ) /\

(moves[step] = moveNb[f1,f2] ) /\

(f = fieldNb[moveNb[f1,f2] , 2 ] ) )

\/

$ s t a r t peg

( ( (moveNb[f,f1] != 0 ) /\

(moves[step] = moveNb[f,f1] ) ) )

)

or removed(6): for move ‘36’ (moving the centre peg(17) to north) there are 2 occurrences ofmovess=36: (boards 17>boards17+1)(movess= 36∨...) (boards 17<boards17+1)(movess= 36∨...)

A typical instance of the state-centric model contains 5,890 common subexpressions, which when eliminated, save 30,039 auxiliary variables (reducing the number of auxiliary vari- ables from 38,750 to 8,711).

Documento similar