Вы находитесь на странице: 1из 8

BLG521E - Lecture 4

Outline BLG521E AdvancedArtificialIntelligence


Lecture4:Constraint SatisfactionProblems
CSPproblemformulation CSPexamples BacktrackingsearchforCSPs Problemstructureandproblemdecomposition LocalsearchforCSPs

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

ConstraintSatisfactionProblems
Search algorithmssofar:
stateisablackbox domainspecificheuristics statesareaccessiblebyproblemspecificroutines

ConstraintSatisfactionProblem
Definedby
nvariablesXi whichdefineastate
EachvariablehasadomainDi ofpossiblevalues

mconstraintsCj
Eachconstraintinvolvessomesubsetofvariables Specifiestheallowablecombinationsofvalues

CSP:
stucturedandsimplerepresentation generalpurposealgorithms

Astateoftheproblem:assignmentofvaluestosome orallofXi s

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

ConstraintSatisfactionProblem
Consistentorlegalassignmentdoesnotviolate constraints Completeassignmentthatsatisfiesallconstraintsisa solution Acomplementaryobjectivefunctionmaybedefined

Example:MapColoring

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

BLG521E - Lecture 4

Example:MapColoring

Constraintgraph
Constraintgraph:nodesarevariables,arcsshow constraints GeneralpurposeCSPalgorithmsusethegraph structure
to speed up search e g Tasmania tospeedupsearch.e.g.,Tasmania

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

Standardsearchformulation
Statesaredefinedbythevaluesassignedsofar
Initialstate:theemptyassignment,{} Successorfunction:assignavaluetoanunassigned variablethatdoesnotconflictwiththecurrentassignment
failifnolegalassignments(notfixable!)

Standardsearchformulation
ThesearchformulationisthesameforallCSPs! Whatisthedepthofsolution?
Whichtypeofsearch?

Goaltest:thecurrentassignmentiscomplete Pathcost:aconstantcostforeverystep

Pathisirrelevant,socanalsousecompletestate formulation
Whichtypeofsearch?

Thenumberofleaves!vspossibleassignments
AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 9 AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 10

VarietiesofCSPs
Discretevariables
finitedomains;sized O(dn)completeassignments
e.g.,BooleanCSPsincluding Booleansatisfiability(NPcomplete)

VarietiesofCSPs
Continuousvariables
e.g.,start/endtimesforHubbleTelescopeobservations linearconstraintssolvableinpolynomial timebyLP methods

infinitedomains(integers,strings,etc.)
e.g.,jobscheduling,variablesarestart/enddaysforeachjob needaconstraintlanguage,e.g.,StartJob1 + 5 StartJob3 linearconstraintssolvable,nonlinearundecidable

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

11

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

12

BLG521E - Lecture 4

Varietiesofconstraints
Unaryconstraintsinvolveasinglevariable
SA green

Varietiesofconstraints
Higherorderconstraintsinvolve3ormorevariables: cryptarithmeticcolumnconstraints
constrainthypergraph canbereducedtobinaryconstraints

Binaryconstraintsinvolvepairsofvariables
SA WA SA

Preferences (soft constraints) Preferences(softconstraints)


redisbetterthangreen oftenencodedusing costsagaintstheoverallobjective function constrainedoptimizationproblems

AbinaryCSPhasonlybinaryconstraints,constraint graphs

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

13

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

14

Example:Cryptarithmetic

RealworldCSPs
Assignmentproblems
whoteacheswhatclass

Timetablingproblems
whichclassisofferedwhenandwhere?


AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 15

Hardwareconfiguration Hardware configuration Spreadsheets Transportationscheduling Factoryscheduling Floorplanning


AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 16

BenefitsofmodelingasaCSP
Representationofstatesconformstoastandard pattern Thesuccessorfunctionandgoaltestcanbewritten inagenericway Devising generic heuristics Devisinggenericheuristics Thestructureoftheconstraintgraphcanbeusedto simplifythesolutionprocess

Backtrackingsearch
Variableassignmentsarecommutative
[WA=redthenNT=green]sameas[NT=greenthen WA=red]

Only need to consider assignments to a single Onlyneedtoconsiderassignmentstoasingle variableateachnode


b=dandtherearedn leaves

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

17

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

18

BLG521E - Lecture 4

Backtrackingsearch
Depthfirstsearchwithsinglevariableassignments ThebasicuninformedalgorithmforCSPs Cansolvenqueensforn 25

Backtrackingsearch

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

19

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

20

Backtrackingexample

Backtrackingexample

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

21

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

22

Backtrackingexample

Backtrackingexample

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

23

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

24

BLG521E - Lecture 4

Improvingbacktrackingefficiency
Generalpurposemethodscangivehugegainsin speed:
Whichvariableshouldbeassignednext? Inwhatordershoulditsvaluesbetried? Canwedetectinevitablefailureearly? y Canwetakeadvantageofproblemstructure?

Minimumremainingvalues
Minimumremainingvalues(MRV):
choosethevariablewiththefewestlegalvalues

Mostconstrainedvariable,failfirstheuristic

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

25

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

26

Degreeheuristic
TiebreakeramongMRVvariables Degreeheuristic:
choosethevariablewiththemostconstraintson remainingvariables

Leastconstrainingvalue
Givenavariable,choosetheleastconstrainingvalue:
theonethatrulesoutthefewestvaluesintheremaining variables

Combiningtheseheuristicsmakes1000queens feasible
AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 27 AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay 28

Forwardchecking
Idea:Keeptrackofremaininglegalvaluesfor unassignedvariables
Terminatesearchwhenanyvariablehasnolegalvalues

Forwardchecking
Idea:Keeptrackofremaininglegalvaluesfor unassignedvariables
Terminatesearchwhenanyvariablehasnolegalvalues

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

29

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

30

BLG521E - Lecture 4

Forwardchecking
Idea:Keeptrackofremaininglegalvaluesfor unassignedvariables
Terminatesearchwhenanyvariablehasnolegalvalues

Forwardchecking
Idea:Keeptrackofremaininglegalvaluesfor unassignedvariables
Terminatesearchwhenanyvariablehasnolegalvalues

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

31

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

32

Constraintpropagation
Forwardcheckingpropagatesinformationfrom assignedtounassignedvariables,butdoesn'tprovide earlydetectionforallfailures

Arcconsistency
Simplestformofpropagationmakeseacharc consistent

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

33

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

34

Arcconsistency
Simplestformofpropagationmakeseacharc consistent

Arcconsistency
Simplestformofpropagationmakeseacharc consistent

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

35

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

36

BLG521E - Lecture 4

Arcconsistency
Simplestformofpropagationmakeseacharc consistent

Arcconsistencyalgorithm

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

37

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

38

kconsistency
Arcconsistencydoesnotrevealeverypossibleinconsistency kconsistency:
foranyk1variablesand foranyconsistentassignment Aconsistentvaluecanbeassignedtoanykth variable

Problemstructure

1consistency:nodeconsistency 1 it d it 2consistency:arcconsistency 3consistency:pathconsistency Agraphisstronglykconsistentifitiskconsistentandalso (k1)consistent,...1consistent

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

39

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

40

Problemstructure

TreestructuredCSPs
Theorem:iftheconstraintgraphhasnoloops,the CSPcanbesolvedinO(nd2)

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

41

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

42

BLG521E - Lecture 4

AlgorithmfortreestructuredCSPs

NearlytreestructuredCSPs

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

43

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

44

IterativealgorithmsforCSPs
Hillclimbing,simulatedannealingtypicallyworkwith completestates,i.e.,allvariablesassigned ToapplytoCSPs:
allowstateswithunsatisfiedconstraints operatorsreassignvariablevalues

Example:4Queens

V i bl Variableselection:randomlyselectanyconflictedvariable l ti d l l t fli t d i bl Valueselectionbyminconflictsheuristic:


choosevaluethatviolatesthefewestconstraints i.e.,hillclimbwithh(n)=totalnumberofviolatedconstraints

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

45

AdvancedArtificialIntelligence(BLG521E)@ITU::ComputerEngineeringDepartment,Dr.SanemSarelTalay

46

Вам также может понравиться