cps(m): constraint satisfaction problem over models (a.k.a rule based design space exploration)

39
Budapest University of Technology and Economics Fault-tolerant Systems Research Group CSP(M): Constraint Satisfaction Problem over Models Ákos Horváth and Dániel Varró

Upload: akos-horvath

Post on 20-Jan-2017

307 views

Category:

Science


0 download

TRANSCRIPT

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group

CSP(M): Constraint Satisfaction Problem over Models

Ákos Horváth andDániel Varró

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

2

Outline

Introduction

CSP(M) ConclusionSolving CSP(M)

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Eight Queens Problem

Place 8 queens on a checkboard without captures

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Constraint Satisfaction Problem

B80,1

A80,1

D80,1

C80,1

F80,1

E80,1

H80,1

G80,1

C70,1

B70,1

E70,1

D70,1

G70,1

F70,1

A70,1

H70,1

B60,1

A60,1

D60,1

C60,1

F60,1

E60,1

H60,1

G60,1

C50,1

B50,1

E50,1

D50,1

G50,1

F50,1

A50,1

H50,1

B40,1

A40,1

D40,1

C40,1

F40,1

E40,1

H40,1

G40,1

C30,1

B30,1

E30,1

D30,1

G30,1

F30,1

A30,1

H30,1

B20,1

A20,1

D20,1

C20,1

F20,1

E20,1

H20,1

G20,1

C10,1

B10,1

E10,1

D10,1

G10,1

F10,1

A10,1

H10,1

Constraint: ∑Ai=1

Variable

Domain

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: LabelingPlace first queen: A8 = 1

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Constraint Propagation

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

Deduce consequences

A7=0

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Labeling

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

Place next queen D6=1

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Constraint Propagation

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0 0

0

0

0

0

0

0

0

0

Deduce consequence

B6=0

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Labeling + Propagation

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0 0

00

0

0

Cannot place Queen on E-file

Backtracking to

last decision

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Backtracking

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0 0

0

0

0

0

0

0

0

0

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Labeling + Propagation

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0

0

0

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Labeling + Propagation

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0 0 0

0

0

If you are smarter, you

can see this is in wrong place

Backjumping to preceding

state

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP: Backjumping

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

Continues with labeling…

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Extensions: Dynamic variables

0 0 0 0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

I50,1

I60,1

I30,1

I40,1

I20,1

Introducing new variables while

solving

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Extensions: Complex labeling

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

How many queens can you

place without captures?

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Extensions: Complex labeling

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Extensions: Complex labeling

0

0

0

0

0

0

0

0

0

0

0 0

0

0

0

0

0

0

0

0

0

0

Placing a new queen invalidates effects of previous constraint

propagation

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Challenges for CSP over ModelsDynamic variablesDynamic constraint managementNative representation for (graph) models

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

19

Outline

Introduction

CSP(M) ConclusionSolving CSP(M)

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

CSP(M)Described by (M0,C,G,L)

− M0 initial model (typed graph)− C set of global constraints (graph patterns)− G set of goals (graph patterns)− L set of labeling rules (GT rules)

Goal− Find a model Ms which satisfies all global

constraints and goals.● One model● All model● Optimal model

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Integrated modular avionics (IMA) system Composed of

− Jobs; Simple Job ,Critical Job − Partitions; compose of jobs− Modules; host partitions

− Cabinets; storage of modules● Max 2

Task− Allocate predefined Jobs on predefined Partitions using

minimal number of Modules

Running Example

1 1

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Running Example: ConstraintsPartition one criticality levelCritical job’s redundant instances on different

Partitions and Modules

Free memory of partition can not be less than zero

● Attribute constraint

1

1 11

12

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

CSP(M): Goal and Global Constraint Graph pattern Satisfied

− Negative● No matching

− Positive● At least one

matching− Cardinality

● |matching| = Cardinality

criticalInstanceonSameModule(Job)

J1: JobInstance

Job: CriticalJob

j1: instances

J2: JobInstance

M1: Module

j2: instances

pr1: partitions

jb1: jobs

P1: Partition P1: Partitionjb2: jobs

pr2 : partitions

partitionwithoutModule(P)

P: Partition

M1: Module NEG

p1:partitions

Global Constraint

Goal

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

CSP(M): Goal and Global Constraint Graph pattern Satisfied

− Negative● No matching

− Positive● At least one

matching− Cardinality

● |matching| = Cardinality

criticalInstanceonSameModule(Job)

J1: JobInstance

Job: CriticalJob

j1: instances

J2: JobInstance

M1: Module

j2: instances

pr1: partitions

jb1: jobs

P1: Partition P1: Partitionjb2: jobs

pr2 : partitions

partitionwithoutModule(P)

P: Partition

M1: Module NEG

p1:partitions

Global Constraint

Goal

No Critical Job instance pair on the

same Module

No Partition without Module

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

CSP(M): Labeling Rule by GT GT rule Applicability

− precondition matches to model

Priority− Precedence relation

Execution mode− Choose (one random)− Forall (all matchings) M1:Module

allocatePartition(P)

P: Partition

M2: ModuleNEG

p1: partitions{NEW}

p2: partitions

createModule()

M : Module{NEW}

Dynamic models− Element

creation/deletion

Labeling Rule

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

26

Outline

Introduction

CSP(M) ConclusionSolving CSP(M)

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP(M)

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

Current State

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP(M)

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

m1

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

allocatePartition

Next state

Transition

New Elements

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP(M)

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

m1

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

allocatePartition

Solution:Satisfies goals and

global constraint

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Solving CSP(M)

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

m1

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1

Mo1Ca

P1

Mem1Mo2

m2

m1

fm1Mo3

allocatePartition

createModule

allocateModule

Goals not satisfiedMo1Ca

P1

Mem1Mo2

m2

m1

fm1Mo3

m3

Global Constraint violated backtracks

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Implementation over VIATRA2Incremental constraint evaluation by

incremental pattern matching− Cached matchings− Incrementally updated

Simple state space representationTyped graph comparison

− DSMDiFFBacktracking

− Transaction on atomic manipulation operations

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

Optimizations

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

Optimizations

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

Optimizations

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

Optimizations

Restriction on the number of rule

applications

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

OptimizationsSame Global

Constraint fails

Merge Global constraint into Labeling rule

precondition

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Search Strategies− Simple Backtracking− Random Backjumping− Guided travelsal by Petri-net abstraction

Constraint optimization− Look-ahead patterns− Exception priority

Evaluation− On average computer (Core duo 1.8 GHz, 2 GB of memory)− Common industrial problem 51 jobs, 7 partitions and 4

cabinets, ● In average first solution in ~120 sec

Optimizations

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

38

Outline

Introduction

CSP(M) ConclusionSolving CSP(M)

Budapest University of Technology and Economics

Fault-tolerant Systems Research Group MODELS '09

Conclusion Summary

− General definition of constraint problems over models● Labeling rules by GT rules● Goals and constraints by GT patterns● Dynamic variables

− Implementation over VIATRA2● Constraint propagation using incremental pattern matching● Dynamically add/remove constraints and labeling rules

Future work− Compact state space representation

● Model differentials● Symbolic state representation● State comparison

− Automatic look-ahead pattern detection (critical pair analysis)

− Comparison with Alloy and Korat