Constraint satisfaction problems and neural networks a statistical physics perspective

合集下载

Classroom Assignment using Constraint Logic Programming

Classroom Assignment using Constraint Logic Programming

Classroom Assignment using Constraint Logic ProgrammingSlim Abdennadher,Matthias Saft and Sebastian WillComputer Science Department,University of MunichOettingenstr.67,80538Munich,Germanyabdennad,saft,wills@informatik.uni-muenchen.deAbstractThe Classroom Assignment problem consists of scheduling a set of courses into afixed number of rooms,given afixed timetable.At the University of Munich,a classroom planhas to be created each semester after collecting timetables of all departments and wishesof teachers.This planning is very complex since a lot of constraints have to be met,e.g.room size and ing constraint-based programming,we developed a prototype,called RoomPlan,that supports automatic creation of classroom plans.With RoomPlan aschedule can be created interactively within some minutes instead of some days.RoomPlanwas presented at the Systems’99Computer exhibition in Munich.1IntroductionUniversity course timetabling problems are combinatorial problems which consist in scheduling a set of courses within a given number of rooms and time periods.In most universities,the university course timetabling problem is solved in two phases.In thefirst phase timetables have to be created,one for each department.Since departments can share rooms,the availability of rooms is not taken into account in thefirst phase.In the second phase,rooms have to be assigned to courses.The assignment of rooms is done centrally for the whole university.The classroom assignment problem is a difficult and time-consuming expert task since a lot of requirements have to be met.For example,courses must be assigned to rooms based on the number of students taking the courses and capacities of rooms.Furthermore,some courses may require special equipments such as beamer or internet access.While for thefirst phase of the university course timetabling several systems have been developed[4,12,7],to our knowledge mainly theoretical work has been done on the topic of the classroom assignment problem[6,5].Recently,Constraint Logic Programming[14,20,11,18](CLP)has become a promising approach for solving scheduling problems.CLP combines the advantages of logic programming and constraint solving techniques.The use of CLP has the advantage that the solving procedure can easily be adapted to changing scheduling characteristics.The classroom assignment prob-lem can be elegantly formalized as a partial constraint satisfaction problem and implemented by means of specialized constraint solving techniques that are available in CLP languages.In this paper,the generation of classroom plans for universities is tackled using the CLP framework.The system is called RoomPlan and is currently tested at the University of Munich.Our prototype brought down the time necessary for creating a classroom plan from a few days by hand to a few minutes on a computer.Usually not all specified requirements can be fulfilled.We distinguish two kinds of con-straints.Hard constraints are conditions that must be satisfied,soft constraints may be violated, but should be satisfied as far as possible.The classical approach to deal with these requirements is based on a variant of branch-and-bound search.This approach starts with a solution and re-quires the next solution to be better.Quality is measured by a suitable cost function.The cost function depends on the set of satisfied soft ually,the computation of the cost function is incorporated into the labeling process.In this paper,we propose another approach computing the cost function during the constraint solving process independent of the labeling procedure.This requires to modify the constraint solving part.In the beginning,constraint solving was“hard-wired”in a built-in constraint solver written in a low-level language,termed the“black-box”approach.Since this approach makes it hard to modify a solver or build a solver over a new domain,our aim was to implement a solver for our problem using the“glass-box”approach Constraint Handling Rules(CHR)[9,10].CHR is a powerful special-purpose declarative programming language for writing application-oriented constraint solvers.For our need,we extended an existingfinite domain solver written in CHR[11]in a way that the cost for a solution is computed during the propagation of soft constraints.CHR allows to express the calculation of the cost in a very declarative and straightforward manner.In this paper,we describe the main features of the constraint solver that was used to generate a classroom plan for the University of Munich.Section2introduces our classroom assignment problem and the constraints that a solution of the problem had to satisfy.Section3shows how the problem can be modelled as a partial constraint satisfaction problem.Section4gives an overview of the implementation.Section5describes the user interface.Finally,we conclude with a summary.2Problem DescriptionIn universities,where each department is responsible for its own timetable and where rooms can be shared by different departments,timetables are usually generated in two phases.In thefirst phase an assignment of courses within a given number of periods is done without taking into account the availability of rooms.This task has to be performed separately for each department.For the Computer Science Department at the University of Munich,thefirst phase is solved automatically by a system that generates a new timetable based on a timetable of the previous year[2,3].For other departments the generation of timetables is still done by hand.In the second phase an assignment of courses within a given number of rooms has to be performed.After collecting timetables of all departments and wishes of teachers a classroom plan is generated centrally.In the following,we want to investigate the classroom assignment problem of the University of Munich.Since timetables for departments change every semester,a new classroom plan has to be created each semester.The University of Munich dispose of different buildings.Thebiggest building consists of40rooms where about1000courses have to be held.The generation of a classroom plan is a difficult and time-consuming task since different kinds of constraints have to be taken into account:The no-occupation overlap constraint tells that occupation time of a room by courses must not overlap.The seat requirement constraint tells how many seats a course requires.The teacher’s wishes:We distinguish three kinds of wishes.–A room constraint binds a course date to a room.–A building constraint assigns a course date to a certain building.–An equipment constraint constrains a course date to be assigned to a room withcertain technical equipment,e.g.beamer or video.Usually not all specified requirements can be fulfilled since the number of(special)rooms is obviously limited.Therefore we distinguish two kinds of constraints.Hard constraints must always be satisfied,soft constraints may be violated.Roughly speaking,no-occupation overlap constraints and seat requirement constraints determine hard constraints,wishes may be hard or soft constraints.3A Constraint Model for Classroom AssignmentA constraint satisfaction problem(CSP)[16]is a pair,where isfinite set of variables, each associated with afinite domain,and is afinite set of constraints on these variables.A solution of a CSP maps each variable to a value of its domain such that all the constraints are satisfied.Since we have to address quality of a room plan and therefore,have to take into account wishes as well as exploitation of resources,CSP can not model our problem completely. Therefore,we use an extension of the CSP concept.A partial constraint satisfaction problem PCSP[8]is a triple,where is a CSP and is a total function, i.e.,maps constraints to weights.The weight of a constraint expresses its importance.Thus, one can describe hard constraints,which must be satisfied,as well as soft constraints,which should be satisfied.A hard constraint is given an infinite weight.Then,a solution of the PCSP is an assignment of the variables in to their domains,such that the total weight of all violated constraints is minimized.Now,the classroom assignment problem is modeled as a PCSP.Note,that it does not suffice to assign a room to each course,but instead we have to assign a room to each date,where a course is held.Therefore,we use one variable for each course date.For example,if a course consists of two lectures,the course is represented by two different course date variables.The initial domain of each course date variable is the set of all rooms in the university.Thus,the solution is an assignment of course dates to rooms.There are two constraints that occur only as hard constraints and thus have infinite weight: the no-occupation overlap constraint and the seat requirement constraint.Wishes may also be hard,i.e.have infinite weight.To ensure a good exploitation of resources by a solution,we evaluate assignments of a room to a course date.For this reason,we modify the weight for the constraint,that assigns a course date for a course to a room.This is done by adding a term to the user-defined evaluation,thus defining in the following way.seats requirement seatequipment(1) where seats is the number of seats in room,requirement seat is the number of seats required by course,equipment is a valuation of the technical equipment in and requirement equipment a value for the technical requirements of.and are negative constants weighting the exploitation of seats and equipment resources against each other and the violation of wishes. Since the equipment constraint can be soft,the value of the technical requirements can be greater than the value of the equipment.In this case,we have to avoid that the third term of the function is positive.4Solving the Problem using Constraint Handling RulesIn a PCSP,one has additionally to satisfying all hard constraints to take soft constraints into account.According to the PCSP model,we have to minimize the total weight of violated soft constraints.This is equivalent to maximize the total weight of satisfied constraints.We use a branch-and-bound approach to tackle this maximization problem.Branch-and-bound is a standard method to optimize a score that works by constraining the score during the search. Every time an assignment satisfying the hard constraints is found,the score is bound to be even better.Thus,the last assignment compatible to the hard constraints that is found will have an optimal score.Therefore,we incrementally compute a bound of the score,that an assignment compatible to the current hard constraints may have,during the enumeration.This way we prune the search tree every time the maximally achievable score is worse than the score of the previous solution.To prune the search tree efficiently in our branch-and-bound algorithm,we have to keep track of the upper bound of the score.The upper bound of the score may be affected each time the constraint store changes.This change may be done either by a constraint which is directly inserted by the labeling process or by constraint propagation.If only changes of thefirst kind could affect the upper bound,the calculation of the score could be easily incorporated into the labeling process.However,since we also have to take care of the second kind of constraint store changes,it is much more natural and intuitive to do this calculation concurrently to the labeling process and triggered by the alteration of the constraint store.Constraint Handling Rules(CHR) allows to express this in a very declarative and straightforward manner,where the calculation is formulated independently of the labeling.In the following,CHR is briefly introduced.Then,the core of the constraint solver,which performs hard and soft constraint propagation,is presented.Finally,a labeling strategy tofind good solutions is described.4.1Constraint Handling RulesCHR is a declarative high-level language extension especially designed for writing constraint solvers.With CHR,one can introduce user-defined constraints into a given host language.The main implementations of CHR are currently available in Prolog:Besides the library from1994, ECL PS 4.0now includes a new experimental prototype of CHR.An advanced optimizing CHR compiler was released for Sicstus3.7in1998[13].CHR has also been implemented in Common Lisp,OZ and Java.To implement the constraint solver for our classroom assignment problem we used the CHR library of Sicstus.Thus,code examples follow the syntax of CHR and Prolog.CHR is essentially a committed-choice language consisting of multi-headed guarded rules that rewrite constraints into simpler ones until they are solved.There are basically two kinds of CHR rules:Simplification rules replace constraints by simpler constraints while preserving log-ical equivalence.Propagation rules add new constraints which are logically redundant but may cause further simplification.Repeatedly applying the rules incrementally solves constraints. With multiple heads and propagation rules,CHR provides two features which are essential for non-trivial constraint handling.Due to space limitations,we cannot give a formal account of syntax and semantics of CHR in this paper.An overview on CHR can be found in[10].Detailed semantics results for CHR are available in[1].We introduce CHR by example.Let=<and=be built-in constraint symbols. We implement a user-defined constraint for max,where max(X,Y,Z)means that Z is the maximum of X and Y:max(X,Y,Z)<=>X=<YZ=X.max(X,Y,Z)==>X=<Z,Y=<Z.Thefirst rule states that max(X,Y,Z)is logically equivalent to Z=Y,provided it is the case that X=<Y.This test forms the guard of a rule,a precondition of the applicability of the rule. Hence,whenever we see the constraint max(X,Y,Z)in any goal where it holds that X=<Y we can simplify it to Z=Y.Analogously for the second rule.Thefirst and second rules are simplification rules.The third rule propagates constraints.It states that max(X,Y,Z)unconditionally implies X=<Z,Y=<Z.Operationally,we add these logical consequences as redundant constraints,the max constraint is kept.This kind of rule is called propagation rule.To the goal max(1,2,M)thefirst rule is applicable:max(1,2,M)will be simplified to M=2.Redundancy from the propagation rule is useful,as the goal max(A,3,3)shows:To this goal only the propagation rule is applicable,but then thefirst rule:max(A,3,3)cause thepropagation rule tofire and adds A=<3,3=3to the goal.Now,thefirst rule is applicable and simplifies the constraint max(A,3,3)to3=3.The constraint33is simplified to true by the built-in constraint solver.The constraint solver for max solved max(A,3,3)and produced the answer A=<3.4.2The Core of the Constraint Solver4.2.1Handling Hard ConstraintsRegarding just the hard constraints,our solver is essentially afinite domain solver,i.e.a course date variable is bound to a list of rooms and constraints may eliminate rooms from the domain list of the constrained variable.Constraint solving forfinite domains constraints is based on consistency techniques[17,15]. For example,the constraints X::[2,3,4]and X::[3,4,5]may be replaced by the new constraint X::[3,4](The constraint X::[2,3,4]means that X has to take a value from the list[2,3,4]).Implementing this technique with CHR is straightforward[11].Thefirst rule ensures that the domain for X is non-empty,the second rule intersects two domains for the same variable:X::[]<=>false.X::L1,X::L2<=>intersection(L1,L2,L),X::L.To solve our classroom assignment problem,the no-occupation overlap constraint can be expressed using the global constraint all distinct(Xs) tells that all variables in the list Xs must be bound to different values.The no-occupation overlap constraint is propagated to constraints allbuilding or equipment.CourseDate holds a course date identifier,the variable Wished further specifies the instance of the wish and Weight holds the weight of the wish.We use further the constraint assignment(CDate,CDateVar)which tells that CDateVar is the course date variable corresponding to the course date CDate.The constraint scoreWish(Up) tells that Up is the upper bound of the sub-score ScoreWish.In the following,we introduce simplification rules to update the sub-score ScoreWish, whenever a wish is satisfied or violated.In the following,we will discuss the rules for handling room constraints.The rules handling building and equipment constraints are analogous. assignment(CDate,CDateVar),CDateVar::Dom,wish(room,CDate,RoomWish,infinite)<=>assignment(CDate,CDateVar),CDateVar::Dom,CDateVar::[RoomWish].assignment(CDate,CDateVar),CDateVar::[RoomWish],wish(room,CDate,RoomWish,Weight)<=>Weight\==infinite|assignment(CDate,CDateVar),CDateVar::[RoomWish]. assignment(CDate,CDateVar),CDateVar::Dom,wish(room,CDate,RoomWish,Weight),scoreWish(Up)<=>Weight\==infinite,\+member(RoomWish,Dom)| assignment(CDate,CDateVar),CDateVar::Dom,scoreWish(Up-Weight).Thefirst rule propagates a hard wish,i.e.a wish with infinite weight,in such a way that an assignment of the course date variable to the wished room is performed.Therefore,the sim-plification rule tests whether constraints of the form assignment(CDate,CDateVar), CDateVar::Dom and wish(room,CDate,RoomWish,infinite)can be found in the constraint store.In this case,the rulefires and the constraint CDateVar::[RoomWish], that binds the room to the wished room,is added to the store.Furthermore,the wish constraint is removed from the constraint store.The application of this rule leads to the occurrence of two domains for the same variable.These constraints can be simplified by the intersection rule presented above.The second rule handles already satisfied soft constraints.If the constraints assign-ment(CDate,CDateVar),CDateVar::[RoomWish]and wish(room,CDate, RoomWish,Weight)are found in the constraint store,then the wish is obviously satisfied and the rule consequently removes the wish.The guard ensures that only soft constraints,i.e. wishes withfinite weight,are handled by this rule,since hard wish constraints are already han-dled by thefirst rule.Note that the upper bound of the score is unaffected if a wish is satisfied. In contrast,if a wish is violated,the upper bound of the score has to be decreased.The updating of the bound is done by the third rule.The guard ensures that only soft constraints which are violated lead to a change of the score.A room constraint is violatedif the wished room is not contained in the domain of the course date variable.If the rule fires,the upper bound is recomputed as Up-Weight and the constraint scoreWish(Up -Weight)replaces the constraint scoreWish(Up).The evaluation of resource exploitation is handled by a single rule.assignment(CDate,CDateVar),CDateVar::[RoomNr],scoreSeatsRes(UpS),scoreEquipmentRes(UpT)<=>assignment(CDate,CDateVar),CDateVar::[RoomNr],scoreSeatsRes_diff(CDate,RoomNr,SSD),scoreEquipmentRes_diff(CDate,RoomNr,TSD),scoreSeatsRes(UpS+SSD),scoreEquipmentRes(UpT+TSD).The rule updates the scores for seat resource and equipment resource exploitation,where the actual weight is calculated by the separate predicates scoreSeatsResdiff analogously to equation(1).The updating of the sub-scores is done by replacing the constraints scoreSeatsRes(UpS)and scoreEquipmentRes(UpT) by the recomputed constraints scoreSeatsRes(UpS+SSD)and scoreEquipmen-tRes(UpT+TSD)each time an assignment of a course date variable to a room was newly created,either by labeling or by constraint propagation.Each time a sub-score is recomputed,the total score has to be recalculated.This can be done by the following propagation rule.scoreWish(UpW),scoreSeatsRes(UpS),scoreEquipmentRes(UpT)==>score(UpC+UpS+UpT).The rulefires if a sub-score changes.Then,a constraint with the newly calculated upper bound of the total score is inserted.A further rule ensures that only the most restrictive score con-straint remains in the constraint store.score(A),score(B)<=>A=<B|score(A).This rule removes the larger of two upper bounds of the total score.Now,the upper bound can be used to prune the search tree,since we use a branch-and-bound algorithm.Every time an assignment of the course date variables that satisfies the hard constraints is found,we insert a constraint last4.3LabelingAfter stating the problem constraints,normally there are still many feasible solutions,so it is necessary to label the domain variables,i.e.assign them with values that remain on their domains.For the labeling one needs to apply a heuristic strategy that tends to enumerate high scoring solutions early in the search.In a branch-and-bound search this helps to prune the search tree.In practice also suboptimal solutions may be appropriate,which also emphasizes the use offinding good solutions early.We employed a leftmost variable,leftmost value strategy that selects for each assignment the leftmost course date variable and the leftmost value from the domain of the selected course date variable.Since we sort the list of variables as well as the values in the domains before the labeling as we describe below,this strategy prefers most constrained assignments.The sorting is done in the following way.We compute a weight for each course and a weight for each room with respect to a certain course,i.e.actually a weight for a certain assignment.The weights for courses respect seat and equipment requirements,such that courses with strong requirements get great weights.The weight of an assignment totals the weights of the soft constraints which are satisfied by the actual assignment.Then,the course date variables and the rooms in each domain are sorted in descending order by these weights.As a consequence the leftmost course date variables,which are selectedfirst by our strategy,belong to the courses with the strongest requirements.Further,the leftmost values in each domain lead to assignments,which satisfy the”best”soft constraints.5User InterfaceFor a classroom assignment system to be complete,aflexible user interface should be provided, so that the specific requirements of the problem can be stated easily.RoomPlan provides such an interface.The RoomPlan user interface was written in JAVA TM1.1using the Abstract Window Toolkit (AWT).It generates the data needed by the CHR solver in form of prolog facts and starts the CHR solver.Figure1shows the input form for the courses that have to be planned.The user has to type in the courses with title,first and last day and start-and endtime.Furthermore,the interface allows the user to define the system parameters as preferred.All parameters like the needed amount of seats and needed equipment,e.g.overhead projector are handled as soft constraints. In addition,the user can specify a wish for a special room.These wishes are given in four cat-egories:imperative,strong preferred,preferred and weakly preferred. Imperative wishes are hard constraints.If there is no wish for a special room,a building can be specified,which is considered by the classroom assignment.It may happen that there exists not even one classroom plan that complies with all the given hard constraints.Then the problem is called over-constrained.In case of a direct clash in form of two conflicting imperative room wishes,RoomPlan may detect this and then gives the user a variety of alternative rooms which satisfy the specified equipment wishes.Figure1:Classroom AssignmentFigure2shows a fragment of the generated classroom plan.In addition,the user can manu-ally alter a completely generated classroom plan and let it check by RoomPlan.An advantage of the interactive system is that the expert might assist the program to produce even better results.6ConclusionIn this paper,we have argued that Constraint Handling Rules(CHR)is a good vehicle for implementing a PCSP solver.We extended an existingfinite domain solver to deal with soft constraints.The idea was to compute the cost function during the propagation of constraints. This is much more natural and intuitive than the incorporation of the computation into the labeling process.Thus our approach is comparable in terms of declarativity to approaches embedding cost functions into a CLP(FD)system using reification.The solver is powerful enough to serve as the core of a classroom assignment system.Our system,RoomPlan,has been implemented using Sicstus Prolog.The CLP code is justabout700lines.RoomPlan assists a human planner in scheduling courses to rooms.Room-Plan was presented at the Systems’99Computer exhibition in Munich.It is currently tested at the University of Munich.Typically,for1000courses and40rooms,RoomPlan generates a satisfying schedule within a few minutes.Figure2:Fragment of a Classroom PlanRoomPlan has been designed to meet the specific requirements of the University of Munich. However,it can be applied to other universities,since the classroom assignment problem is already handled in a general way.However,if necessary,adaption can easily be done due to the the declarativity of constraint logic programming.In general problems a labeling strategy with previouslyfixed enumeration order is not suit-able,since a good order of variables or domain values often cannot befixed in advance.Only thespecial nature of our classroom assignment problem makes this strategy a suitable choice.Nev-ertheless,we are currently developing intelligent labeling strategies as quoted by Tsang[19]. AcknowledgementsWe would like to thank Thom Fr¨u hwirth and the anonymous referees for useful comments on a preliminary version of this paper.References[1]S.Abdennadher.Operational semantics and confluence of constraint propagation rules.InThird International Conference on Principles and Practice of Constraint Programming, CP’97,LNCS1330.Springer-Verlag,1997.[2]S.Abdennadher and M.Marte.University timetabling using constraint handling rules.InActes des Journ´e es Francophones de Programmation en Logique et Programmation par Contraintes,1998.[3]S.Abdennadher and M.Marte.University course timetabling using constraint handlingrules.Journal of Applied Artificial Intelligence,Special Issue on Constraint Handling Rules,to appear2000.[4]F.Azevedo and P.Barahona.Timetabling in constraint logic programming.In Proceedingsof2nd World Congress on Expert Systems,1994.[5]M.Carter and C.Tovey.When is the classroom assignment problem hard?OperationsResearch,40(1):28–39,1989.[6]J.Ferland and S.Roy.Timetabling problem for university as assignment of activity toputers and Operational Research,12(2):207–218,1985.[7]H.Frangouli,V.Harmandas,and P.Stamatopoulos.UTSE:Construction of optimumtimetables for university courses—A CLP based approach.In Proceedings of the Third International Conference on the Practical Applications of Prolog,pages225–243,1995.[8]E.C.Freuder and R.J.Wallace.Partial constraint satisfaction.Artificial Intelligence,58(1-3):21–70,December1992.[9]T.Fr¨u hwirth.Constraint handling rules.In A.Podelski,editor,Constraint Programming:Basics and Trends,LNCS910.Springer-Verlag,1995.[10]T.Fr¨u hwirth.Theory and practice of constraint handling rules,special issue on constraintlogic programming.Journal of Logic Programming,pages95–138,October1998.[11]T.Fr¨u hwirth and S.Abdennadher.Constraint-Programmierung:Grundlagen und Anwen-dungen.Springer-Verlag,September1997.[12]M.Henz and J.W¨u ing Oz for college time tabling.In Proceedings of the FirstInternational Conference on the Practice and Theory of Automated Timetabling,pages 283–296,1995.[13]C.Holzbaur and T.Fr¨u hwirth.A prolog constraint handling rules compiler and runtimesystem.Journal of Applied Artificial Intelligence,Special Issue on Constraint Handling Rules,to appear2000.[14]J.Jaffar and M.J.Maher.Constraint logic programming:A survey.Journal of LogicProgramming,20,1994.[15]V.Kumar.Algorithms for constraint-satisfaction problems:A survey.AI Magazine,13(1),1992.[16]A.K.Mackworth.Consistency in networks of relations.Artificial Intelligence,8:99–118,1977.[17]A.K.Mackworth.Constraint satisfaction.In S.C.Shapiro,editor,Encyclopedia ofArtificial Intelligence.Wiley,1992.V olume1,second edition.[18]K.Marriott and P.Stuckey.Programming with Constraints:An Introduction.The MITPress,1998.[19]E.Tsang.Foundations of Constraint Satisfaction.Academic Press,1993.[20]M.Wallace.Practical applications of constraint programming.Constraints Journal,1(1,2),September1996.。

m5-csp

m5-csp

4 Feb 2004
Combining these heuristics makes 1000 CS 3243 - Constraint Satisfaction queens feasible
b = d and there are $d^n$ leaves
Depth-first search for CSPs with single-variable assignments is called backtracking search
Backtracking search is the basic uninformed algorithm for CSPs
4 Feb 2004 CS 3243 - Constraint Satisfaction 7
Varieties of constraints
Unary constraints involve a single variable,
e.g., SA ≠ green
Binary constraints involve pairs of variables,
4 Feb 2004
CS 3243 - Constraint Satisfaction
14
Backtracking example
4 Feb 2004
CS 3243 - Constraint Satisfaction
15
Backtracking example
4 Feb 2004
CS 3243 - Constraint Satisfaction
Simple example of a formal representation language
4 Feb 2004 CS 3243 - Constraint Satisfaction 3

Robust solutions for constraint satisfaction and optimization

Robust solutions for constraint satisfaction and optimization

Robust Solutions for Constraint Satisfaction and Optimization Emmanuel Hebrard and Brahim Hnich and Toby WalshCork Constraint Computation CentreUniversity College Cork,Ireland.email: e.hebrard,b.hnich,tw@4c.ucc.ieAbstractSuper solutions are solutions in which,if a small num-ber of variables lose their values,we are guaranteed tobe able to repair the solution with only a few changes.In this paper,we stress the need to extend the super so-lution framework in several dimensions to make it moreuseful practically.We demonstrate the usefulness ofthose extensions on an example from jobshop schedul-ing,an optimization problem solved through constraintsatisfaction.In such a case there is indeed a trade-offbetween optimality and robustness,however robustnessmay be increased without sacrificing optimality.IntroductionMany AI problems may be modeled as constraint satisfac-tion and optimization problems.However,the real worldis subject to change:machines may break,drivers may getsick,stock prices increase or decrease,etc.In such cases,our solutions to the problems may”break”.In this context,one may want a solution to be robust,that is able to re-main valid despite changes.Supermodels were introduced in(Ginsberg,Parkes,&Roy1998)as a framework to measureinherent degrees of solution stability.They are propositionalsatisfiability models with good properties of the neighbor-hood ensuring a close alternative in case of breakage.Thisnotion extends to constraint satisfaction:an-super-solution((Hebrard,Hnich,&Walsh2004))is a solution suchthat the loss of the values of at most variables in can berepaired by assigning other values to these variables,andmodifying the assignment of at most other variables.Wecall this new solution(with at most variables reas-signed)a repair solution.Consider the following CSP:is a-super-solution since for anyloss of value of any single variable,another solution may befound by changing at most one other variable.For instance,a break on A is repaired by the following solution:The problem of determining the existence of a super-solution has been proved to be NP-complete for afixedEach job is a sequence of activities,where each activity has a duration for its execution on one of the machines.The objective is to schedule the activities such that their order is respected,no machine is required by two activities that overlap,and the makespan,i.e.,the interval from the start-ing point of the first activity,and ending point of the last,is minimized.A jsp can be formulated as a CSP,with one variable for each activity,and a domain size equal to the makespan mi-nus its duration.To find the minimal makespan,one start with the makespan equal to a lower bound and increase it till a solution exists.The following figure represents a jsp with 4jobs and 4machines.Bars are activities,organized in jobs.Their length are proportional to their duration.Each job’s activities have the same border (respectively solid,dashed,dotted,dash and two dots),whilst colors correspond to machines.Job 1:Job 2:Job 3:Job 4:The second figure shows an optimalsolution.M 1:M 2:M 3:M 4:Activities are now scheduled on each machine.One may argue that this solution is not robust.Indeed activities are tightly grouped and a “break”on a machine,and the sub-sequent delay,may trigger further delays in the schedule.Now,consider a -super-solution for thisinstance:M 1:M 2:M 3:M 4:It’s important to say that until now no assumption were made about the problem solved,and about what might be a robust solution to that problem.Nevertheless,with a small increase in the makespan,we observe that a super-solution for a jsp contains more slacks between activities,making it more robust.However,this is not really satisfying.Indeed,the values are time points,the breakages are known only when they occur,thus we might want to change only events in the future.The next figure shows a super-solution with this (alternative value)restriction:M 1:M 2:M 3:M 4:This solution seems clearly more robust than the first one.However,the makespan increase is relatively impor-tant.One alternative,which ensure a small makespan is to optimize the repairability ,i.e,the proportion of repairable variables.For instance suppose that we don’t want the makespan to increase of more than two time units.The nextfigure shows a solution with optimal repairability (i.e.,more robust)whilst the makespan length isrestricted:M 1:M 2:M 3:M 4:There are a number of such improvements upon classicalsuper-solution that we can gather from our knowledge of the problem.For instance,some machines may be reliable,one would then restrict the break-set accordingly.Moreover,the slacks should be linked to the duration for repairing a partic-ular machine,this can be done by restricting the alternative values.Another example is the instruction scheduling problem,where primitive instructions of a program are to be sched-uled in order to minimize the time complexity of the pro-gram while keeping its semantic.When we model this prob-lem,a variable can take the value “NOP”,which stands for “no operation”.Whilst a breakage may happen on any vari-able,one assigned to “NOP”cannot break.When some vari-ables are set to such an assignment,no witness of repairabil-ity is required.Note that super-solutions offers no real dif-ficulties to adapt to the optimization framework.However,it’s not surprising that one has to sacrifice optimality in order to achieve robustness.An alternative is to optimize the re-pairability of a solution,that is the proportion of repairable breaks,without giving up optimality,or at least bounding the loss.More generally we have now a multi-criteria opti-mization problem.ConclusionWe claim that super-solutions offer a nice framework to ob-tain more robust solution to constraint satisfaction or opti-mization problems.They are often a good starting point for characterizing robustness,without requiring any knowledge of the problem.However,we showed that integrating spe-cific information about a problem can lead to much better results.In our future work we plan to define and implement a library of useful predicates and optimization criteria that can be used and combined in order to easily post robustness constraints.Our algorithm would simply use the appropri-ate predicates to check the validity of any repair.Then we would like to use this framework to obtain robust solutions of real problems subject to uncertainty.ReferencesBessiere,C.,and Regin,J.-C.1996.MAC and combined heuristics:Two reasons to forsake FC (and CBJ?)on hard problems.In Proceedings CP’96,61–75.Ginsberg,M.;Parkes,A.;and Roy,A.1998.Supermodels and robustness.In Proceedings AAAI’98,334–339.Hebrard, E.;Hnich, B.;and Walsh,T.2004.Su-per solutions in constraint programming.In Proceedings CPAIOR’04(to appear).Sabin,D.,and Freuder,E.1994.Contradicting Conven-tional Wisdom in Constraint Satisfaction.In Borning,A.,ed.,Proceedings CP’94,volume 874,10–20.。

人工智能原理 北京大学 6 PartIISearchingChapter6Constrain (6.1.1)

人工智能原理 北京大学 6  PartIISearchingChapter6Constrain (6.1.1)

Constraint Satisfaction Problems (CSPs)School of Electronic and Computer EngineeringPeking UniversityWang Wenmin☐6.1.1 What are Constraint Satisfaction Problems (CSPs)☐6.1.2 Standard Search vs. Constraint Satisfaction Problem ☐6.1.3 Why Study Constraint Satisfaction Problem☐6.1.4 Formal Definition of CSP☐6.1.5 Appendix: Four Color Theorem☐6.1.6 Why Formulate a Problem as a CSP☐6.1.7 Variations on the CSP Formalism☐6.1.8 Cryptarithmetic☐6.1.9 A Theoretical Aspect of CSPs: Decision Problems ☐6.1.10 Real-World CSPs☐6.1.11 Resolution of CSPsWhat are Constraint Satisfaction Problem (CSPs) 什么是约束满足问题☐CSPs are mathematical problems, defined as a set of objects whose state must satisfy a number of constraints or limitations.CSPs是数学问题,被定义为其状态必须满足若干约束和限制的一组对象。

☐CSPs represent the entities in a problem as a homogeneous collection of finite constraints over variables, which is solved by constraint satisfaction methods.CSPs将问题中的实体表示为对变量进行有限约束的同质集合,通过约束满足方法加以解决。

Finite Model Theory and Its Applications

Finite Model Theory and Its Applications

Finite Model Theory and Its ApplicationsSpringer61Constraint Satisfactionthe data complexity of a fragment of existential second-order logic.We then go on in Section1.6and offer a logical approach,via definability in Datalog, to establishing the tractability of non-uniform constraint-satisfaction prob-lems.In Section1.7,we leverage the connection between Datalog and certain pebble games,and show how these pebble games offer an algorithmic ap-proach to solving uniform constraint-satisfaction problems.In Section1.8,we relate these pebble games to consistency properties of constraint-satisfaction instances,a well-known approach in constraint solving.Finally,in Section1.9, we show how the same pebble games can be used to identify large“islands of tractability”in the constraint-satisfaction terrain that are based on the concept of bounded treewidth.Much of the logical machinery used in this chapter is described in detail in Chapter??.For a book-length treatment of constraint satisfaction from the perspective of graph homomorphism,see[44].Two books on constraint programming and constraint processing are[3,23].1.2PreliminariesThe standard terminology in AI formalizes an instance P of constraint satis-faction as a triple(V,D,C),where1.V is a set of variables;2.D is a set of values,referred to as the domain;3.C is a collection of constraints C1,...,C q,where each constraint C i is apair(t,R)with t a k-tuple over V,k≥1,referred to as the scope of the constraint,and R a k-relation on D.A solution of such an instance is a mapping h:V→D such that,for each constraint(t,R)in C,we have that h(t)∈R,where h is defined on tuples component-wise,that is,if t=(a1,...,a k),then h(t)=(h(a1),...,h(a k)). The constraint-satisfaction problem asks whether a given instance is solvable,i.e.,whether it has a solution.Note that,without loss of generality, we may assume that all constraints(t,R i)involving the same scope t have been consolidated to a single constraint(t,R),where R is the intersection of all relations R i constraining t.Thus,we can assume that each tuple t of variables occurs at most once in the collection C.Consider the Boolean satisfiability problem3-Sat:given a3CNF-formula ϕwith variables x1,...,x n and clauses c1,...,c m,isϕsatisfiable?Such an instance of3-Sat can be thought of as the constraint-satisfaction instance in which the set of variables is V={x1,...,x n},the domain is D={0,1},and the constraints are determined by the clauses ofϕ.For example,a clause of the form(¬x∨¬y∨z)gives rise to the constraint((x,y,z),{0,1}3−{(1,1,0)}). In an analogous manner,3-Colorability can be modelled as a constraint-satisfaction problem.Indeed,an instance G=(V,E)of3-Colorability can be thought of as the constraint-satisfaction instance in which the set1.2Preliminaries7 of variables is the set V of the nodes of the graph G,the domain is the set D={r,b,g}of three colors,and the constraints are the pairs((u,v),Q), where(u,v)∈E and Q={(r,b)(b,r),(r,g)(g,r),(b,g)(g,b)}is the disequality relation on D.Let A and B be two relational structures1over the same vocabulary.A homomorphism h from A to B is a mapping h:A→B from the universe A of A to the universe B of B such that,for every relation R A of A and every tuple (a1,...,a k)∈R A,we have that(h(a1),...,h(a k))∈R B.The existence of a homomorphism from A to B is denoted by A→B,or by A→h B,when we want to name the homomorphism h explicitly.An important observation made in[29]2is that every such constraint-satisfaction instance P=(V,D,C)can be viewed as an instance of the homomorphism problem,asking whether there is a homomorphism between two structures A P and B P that are obtained from P in the following way:1.the universe of A P is V and the universe of B P is D;2.the relations of B P are the distinct relations R occurring in C;3.the relations of A P are defined as follows:for each distinct relation R onD occurring in C,we have the relation R A={t:(t,R)∈C}.Thus,R Aconsists of all scopes associated with R.We call(A P,B P)the homomorphism instance of P.Conversely,it is also clear that every instance of the homomorphism problem between two struc-tures A and B can be viewed as a constraint-satisfaction instance CSP(A,B) by simply“breaking up”each relation R A on A as follows:we generate a con-straint(t,R B)for each t∈R A.We call CSP(A,B)the constraint-satisfaction instance of(A,B).Thus,as pointed out in[29],the constraint-satisfaction problem can be identified with the homomorphism problem.To illustrate the passage from the constraint-satisfaction problem to the homomorphism problem,let us consider3-Sat.A3CNF-formulaϕwith vari-ables x1,...,x n and clauses c1,...,c m gives rise to a homomorphism instance (Aϕ,Bϕ)defined as follows:•Aϕ=({x1,...,x n},Rϕ0,Rϕ1,Rϕ2,Rϕ3),where Rϕi is the ternary relation consisting of all triples(x,y,z)of variables that occur in a clause ofϕwith i negated literals,0≤i≤3;for instance,Rϕ2consists of all triples (x,y,z)of variables such that(¬x∨¬y∨z)is a clause ofϕ(here,we assume without loss of generality that the negated literals precede the positive literals).•Bϕ=({0,1},R0,R1,R2,R3),where R i consists of all triples that satisfy a3-clause in which thefirst i literals are negated;for instance,R2= {0,1}3−{1,1,0}.Note that Bϕdoes not depend onϕ.It is clear thatϕis satisfiable if and only if there is a homomorphism from Aϕto Bϕ(in symbols,Aϕ→Bϕ).81Constraint SatisfactionAs another example,3-Colorability is equivalent to the problem of de-ciding whether there is a homomorphism h from a given graph G to the com-plete graph K3=({r,b,g},{(r,b)(b,r),(r,g)(g,r),(b,g)(g,b)}with3nodes. More generally,k-Colorability,k≥2,amounts to the existence of a ho-momorphism from a given graph G to the complete graph K k with k nodes (also known as the k-clique).Numerous other important NP-complete problems can be viewed as special cases of the Homomorphism Problem(and,hence,also of the Constraint-Satisfaction Problem).For example,consider the Clique problem:given a graph G and an integer k,does G contain a clique of size k?As a homo-morphism instance this is equivalent to asking if there is a homomorphism from the complete graph K k to G.As a constraint-satisfaction instance,the set of variables is{1,2,...,k},the domain is the set V of nodes of G,and the constraints are the pairs((i,j),E)such that i=j,1≤i,j≤k,and E is the edge relation of G.For another example,consider the Hamiltonic-ity Problem:given a graph G=(V,E)does it have a Hamiltonian cycle? This is equivalent to asking if there is a homomorphism from the structure (V,C V,=)to the structure(V,E,=),where C V is some cycle on the set V of nodes of G and=is the disequality relation on V.NP-completeness of the Homomorphism problem was pointed out explicitly in[53].In this chapter, we use both the traditional AI formulation of constraint satisfaction and the formulation as the homomorphism problem,as each has its own advantages.It turns out that in both formulations constraint satisfaction can be ex-pressed as a database-theoretic problem.We start with the homomorphism formulation,which is intimately related to conjunctive-query evaluation[48].A conjunctive query Q of arity n is a query definable by a positive existential first-order formulaϕ(X1,...,X n)having conjunction as its only propositional connective,that is,by a formula of the form∃Z1...∃Z mψ(X1,...,X n,Z1,...,Z m),whereψ(X1,...,X n,Z1,...,Z m)is a conjunction of(positive)atomic formu-las.The free variables X1,...,X n of the defining formula are called the distin-guished variables of Q.Such a conjunctive query is usually written as a rule, whose head is Q(X1,...,X n)and whose body isψ(X1,...,X n,Z1,...,Z m). For example,the formula∃Z1∃Z2(P(X1,Z1,Z2)∧R(Z2,Z3)∧R(Z3,X2))defines a binary conjunctive query Q,which as a rule becomesQ(X1,X2):-P(X1,Z1,Z2),R(Z2,Z3),R(Z3,X2).If the formula defining a conjunctive query Q has no free variables(i.e.,if it is a sentence),then Q is a Boolean conjunctive query.For example,the sentence∃Z1∃Z2∃Z3(E(Z1,Z2)∧E(Z2,Z3)∧E(Z3,Z1))1.2Preliminaries9 defines the Boolean conjunctive query“is there a cycle of length3?”.If D is a databaseand Q is a n-ary query,then Q(D)is the n-ary relationon D obtained by evaluating the query Q on D,that is,the collection of all n-tuples from D that satisfy the query(cf.Chapter??).The conjunctive-query evaluation problem asks:given a n-ary query Q,a database D, and a n-tuple a from D,does a∈Q(D)?Let Q1and Q2be two n-aryqueries having the same tuple of distinguished variables.We say that Q1iscontained in Q2,and write Q1⊆Q2,if Q1(D)⊆Q2(D)for every database D.The conjunctive-query containment problem asks:given two con-junctive queries Q1and Q2,is Q1⊆Q2?These concepts can be defined forBoolean conjunctive queries in an analogous manner.In particular,if Q is a Boolean query and D is a database,then Q(D)=1if D satisfies Q;otherwise,Q(D)=0.Moreover,the containment problem for Boolean queries Q1and Q2is equivalent to asking whether Q1logically implies Q2.It is well known that conjunctive-query containment can be reformu-lated both as a conjunctive-query evaluation problem and as a homomor-phism problem.What links these problems together is the canonical databaseD Q associated with Q.This database is defined as follows.Each variableoccurring in Q is considered a distinct element in the universe of D Q.Ev-ery predicate in the body of Q is a predicate of D Q as well;moreover,for every distinguished variable X i of Q,there is a distinct monadic pred-icate P i(not occurring in Q).Every subgoal in the body of Q gives rise toa tuple in the corresponding predicate of D Q;moreover,if X i is a distin-guished variable of Q,then P i(X i)is also a(monadic)tuple of D Q.Thus, returning to the preceding example,the canonical database of the conjunctivequery∃Z1∃Z2(P(X1,Z1,Z2)∧R(Z2,Z3)∧R(Z3,X2))consists of the factsP(X1,Z1,Z2),R(Z2,Z3),R(Z3,X2),P1(X1),P2(X2).The relationship be-tween conjunctive-query containment,conjunctive-query evaluation,and ho-momorphisms is provided by the following classical result,due to Chandra and Merlin.Theorem1.1.[11]Let Q1and Q2be two conjunctive queries having thesame tuple(X1,...,X n)of distinguished variables.Then the following state-ments are equivalent.•Q1⊆Q2.•(X1,...,X n)∈Q2(D Q1).•There is a homomorphism h:D Q2→D Q1.It follows that the homomorphism problem can be viewed as a conjunctive-query evaluation problem or as a conjunctive-query containment problem.Forthis,with every structure A,we view the universe A={X1,...,X n}of A as aset of individual variables and associate with A the Boolean conjunctive query ∃X1...∃X n∧t∈R A R(t);we call this query the canonical conjunctive query of A and denote it by Q A.It is clear that A is isomorphic to the canonicaldatabase associated with Q A.101Constraint SatisfactionCorollary1.2.Let A and B be two structures over the same vocabulary. Then the following statements are equivalent.•A→B.•B|=Q A.•Q B⊆Q A.As an illustration,we have that a graph G is3-colorable iffK3|=Q G iff⊆Q G.Q K3A relational join,denoted by the symbol1,is a conjunctive query with no existentially quantified variables.Thus,relational-join evaluation is a special case of conjunctive-query evaluation.For example,E(Z1,Z2)∧E(Z2,Z3)∧E(Z3,Z1)is a relational join that,when evaluated on a graph G=(V,E), returns all triples of nodes forming a3-cycle.There is a well known connec-tion between the traditional AI formulation of constraint satisfaction and relational-join evaluation that we describe next.Suppose we are given a constraint-satisfaction instance(V,D,C).We can assume without loss of gen-erality that in every constraint(t,R)∈C the elements in t are distinct. (Suppose to the contrary that t i=t j.Then we can delete from R every tu-ple in which the i th and j th entries disagree,and then project out that j-th column from t and R.)We can thus view every element of V as a relational attribute,every tuple of distinct elements of V as a relational schema,and every constraint(t,R)as a relation R over the schema t(cf.[1]).It now fol-lows from the definition of constraint satisfaction that CSP can be viewed as a relational-join evaluation problem.Proposition1.3.[6,42]A constraint-satisfaction instance(V,D,C)is solv-able if and only if1(t,R)∈C R is nonempty.Note that Proposition1.3is essentially the same as Corollary1.2.Indeed, the condition B|=Q A amounts to the non-emptiness of the relational join obtained from Q A by dropping all existential quantifiers and using the rela-tions from B as interpretations of the relational symbols in Q A.Moreover, the homomorphisms from A to B are precisely the tuples in the relational join associated with the constraint-satisfaction instance CSP(A,B).1.3Computational Complexity of Constraint SatisfactionThe Constraint-Satisfaction Problem is NP-complete,because it is clearly in NP and also contains NP-hard problems as special cases,including 3-Sat,3-Colorability,and Clique.As explained in Garey and Johnson’s classic monograph[36],one of the main ways to cope with NP-completeness is to identify polynomial-time solvable cases of the problem at hand that are obtained by imposing restrictions on the possible inputs.For instance,1.3Computational Complexity of Constraint Satisfaction11 Horn3-Sat,the restriction of3-Sat to Horn3CNF-formulas,is solvable in polynomial-time using a unit-propagation algorithm.Similarly,it is known that3-Colorability restricted to graphs of bounded treewidth is solvable in polynomial time(see[26]).In the case of constraint satisfaction,the pursuit of tractable cases has evolved over the years from the discovery of isolated cases to the discovery of large“islands of tractability”of constraint satisfaction.In what follows,we will give an account of some of the progress made in this ing the fact that the Constraint-Satisfaction Problem can be identified with the Homomorphism Problem,we begin by introducing some terminology and notation that will enable us to formalize the concept of an “island of tractability”of constraint satisfaction.In general,an instance of the Homomorphism Problem consists of two relational structures A and B.Thus,all restricted cases of this problem can be obtained by imposing restrictions on the input structures A and B.Definition1.4.Let A,B be two classes of relational structures.We write CSP(A,B)to denote the restriction of the Homomorphism Problem to in-put structures from A and B.In other words,CSP(A,B)={(A,B):A∈A,B∈B and A→B}.An island of tractability of constraint satisfaction is a pair(A,B)of classes of relational structures such that CSP(A,B)is in the complexity class PTIME of all decision problems solvable in polynomial time.(A more general definition of islands of tractability of constraint satisfaction would consider classes of pairs(A,B)of structures,cf.[28];we do not pursue this more general definition here.)The ultimate goal in the pursuit of islands of tractability of constraint sat-isfaction is to identify or characterize classes A and B of relational structures such that CSP(A,B)is in PTIME.The basic starting point in this investiga-tion is to consider the cases in which one of the two classes A,B is as small as possible,while the other is as large as possible.This amounts to considering the cases in which one of A,B is the class All of all relational structures over some arbitrary,butfixed,relational vocabulary,while the other is a single-ton,consisting of somefixed structure over that vocabulary.Thus,the start-ing points of the investigation is to determine,forfixed relational structures A,B,the computational complexity of the decision problems CSP({A},All) and CSP(All,{B}).Clearly,for eachfixed A,the decision problem CSP({A},All)can be solved in polynomial time,because,given a structure B,the existence of a homomorphism from A to B can be checked by testing all functions h from the universe A of A to the universe B of B(the total number of such functions is|B||A|,which is a polynomial number in the size of the structure B when A isfixed).Thus,having a singleton structure“on the left’is of little interest.At the other extreme,however,the situation is quite different,since the computational complexity of CSP(All,{B})may very well depend on the121Constraint Satisfactionparticular structure B.Indeed,CSP(All,{K3})is NP-complete,because it is the3-Colorability problem;in contrast,CSP(All,{K2})is in P,because it is the2-Colorability problem.For simplicity,in what follows,for every fixed structure B,we define CSP(B)=CSP(All,{B})and call this the non-uniform constraint-satisfaction problem associated with B.For such problems, we refer to B as the template.Thus,thefirst major goal in the study of the computational complexity of constraint satisfaction is to identify those templates B for which CSP(B)is in PTIME.This goals gives rise to an important open decision problem.The Tractability Classification Problem:Given a relational structure B,decide if CSP(B)is in PTIME.In addition to the family of non-uniform constraint-satisfaction problems CSP(B),where B is a relational structure,we also study decision problems of the form CSP(A,All),where A is a class of structures.We refer to such problems as uniform constraint-satisfaction problems.It is illuminating to consider the complexity of uniform and non-uniform constraint satisfaction from the perspective of query evaluation.As argued in[67](see Chapter??),there are three ways to measure the complexity of evaluating queries(we focus here on Boolean queries)expressible in a query language L:•The combined complexity of L is the complexity of the following decision problem:given an L-query Q and a structure A,does A|=Q?In symbols,{ Q,A :Q∈L and A|=Q}.•The expression complexity of L is the complexity of the following decision problems,one for eachfixed structure A:{Q:Q∈L and A|=Q}.•The data complexity of L is the complexity of the following decision prob-lems,one for eachfixed query Q∈L:{A:A|=Q}.As discussed in Chapter??,the data complexity offirst-order logic is in LOGSPACE,which means that,for eachfirst-order query Q,the problem {A:A|=Q}is in LOGSPACE.In contrast,the combined complexity for first-order logic is PSPACE-complete.Furthermore,the expression complex-ity forfirst-order logic is also PSPACE-complete.In fact,for all but trivial structures A,the problem{Q:Q∈F O and A|=Q}is PSPACE-complete. This exponential gap between data complexity,on one hand,and combined and expression complexity,on the other hand,is typical[67].For conjunc-tive queries,on the other hand,both combined and expression complexity are NP-complete.1.4Non-Uniform Constraint Satisfaction13Consider now the uniform constraint-satisfaction problem CSP(A,All)= {(A,B):A∈A,and A→B},where A is a class of structures.By Corol-lary1.2,we have thatCSP(A,All)={(A,B):A∈A,B is a structure and B|=Q A}.Thus,studying the complexity of uniform constraint satisfaction amounts to studying the combined complexity for a class of conjunctive queries,as, for example,in[12,39,62].In contrast,consider the non-uniform constraint-satisfaction problem CSP(B)={A:A→B}.By Corollary1.2we have that CSP(B)={A:B|=Q A}.Thus,studying the complexity of non-uniform constraint satisfaction amounts to studying the expression complexity of conjunctive queries with respect to different structures.This is a problem that has not been studied in the context of database theory.1.4Non-Uniform Constraint SatisfactionThefirst major result in the study of non-uniform constraint-satisfaction problems was obtained by Schaefer[63],who,in effect,classified the compu-tational complexity of all Boolean non-uniform constraint-satisfaction prob-lems.A Boolean structure is simply a relational structure with a2-element universe,that is,a structure of the form B=({0,1},R B1,...,R B m).A Boolean non-uniform constraint-satisfaction problem is a problem of the form CSP(B)with a Boolean template B.These problems are also known as Generalized-Satisfiability Problems,because they can be viewed as variants of Boolean-satisfiability problems in which the formulas are conjunc-tions of generalized connectives[36].In particular,they contain the well known problems k-Sat,k≥2,1-in-3-Sat,Positive1-in-3-Sat,Not-All-Equal 3-Sat,and Monotone3-Sat as special cases.For example,as seen ear-lier,3-Sat is CSP(B),where B=({0,1},R0,R1,R2,R3)and R i is the set of all triples that satisfy a3-clause in which thefirst i-literals are negated, i=0,1,2,3(thus,R0={0,1}3−{(0,0,0)}).Similarly,Monotone3-SAT is CSP(B),where B=({0,1},R0,R3).Ladner[51]showed that if PTIME=NP,then there are decision problems in NP that are neither NP-complete,nor belong to PTIME.Such problems are called intermediate problems.Consequently,it is conceivable that a given family of NP-problems contains intermediate problems.Schaefer[63],how-ever,showed that the family of all Boolean non-uniform constraint-satisfaction problems contains no intermediate problems.Theorem1.5.(Schaefer’s Dichotomy Theorem[63])•If B=({0,1},R B1,...,R B m)is Boolean structure,then either CSP(B)is in PTIME or CSP(B)is NP-complete.141Constraint Satisfaction•The Tractability Classification Problem for Boolean structures is decidable;in fact,there is a polynomial-time algorithm to decide,given a Boolean structure B,whether CSP(B)is in PTIME or is NP-complete.Schaefer’s Dichotomy Theorem can be described pictorially as follows:NP-completeCSP(B)PSchaefer[63]actually showed that there are exactly six types of Boolean structures such that CSP(B)is in PTIME,and provided explicit descriptions of them.Specifically,he showed that CSP(B)is in PTIME precisely when at least one of the following six conditions is satisfied:•Every relation R B i,1≤i≤m,of B is0-valid,that is,R B i contains the all-zeroes tuple(0,...,0).•Every relation R B i,1≤i≤m,of B is1-valid,that is,R B i contains the all-ones tuple(1,...,1).•Every relation R B i,1≤i≤m,of B is bijunctive,that is,R B i is the set of truth assignments satisfying some2-CNF formula.•Every relation R B i,1≤i≤m,of B is Horn,that is,R B i is the set of truth assignments satisfying some Horn formula.•Every relation R B i,1≤i≤m,of B is dual Horn,that is,R B i is the set of truth assignments satisfying some dual Horn formula.•Every relation R B i,1≤i≤m,of B is affine,that is,R B i is the set of solutions to a system of linear equations over the two-elementfield.Schaefer’s Dichotomy Theorem established a dichotomy and a decidable classification of the complexity of CSP(B)for Boolean templates B.After this, Hell and Neˇs etˇr il[43]established a dichotomy theorem for CSP(B)problems in which the template B is an undirected graph:if B is bipartite,then CSP(B) is solvable in polynomial time;otherwise,CSP(B)is NP-complete.To illus-trate this dichotomy theorem,let C n,n≥3,be a cycle with n elements.Then CSP(C n)is in PTIME if n is even,and is NP-complete if n is odd.The preceding two dichotomy results raise the challenge of classifying the computational complexity of CSP(B)for arbitrary relational templates B. Addressing this question,Feder and Vardi[29]formulated the following con-jecture.Conjecture1.6.(Dichotomy Conjecture)[29]If B=(B,R B1,...,R B m)is an arbitrary relational structure,then either CSP(B)is in PTIME or CSP(B)is NP-complete.1.4Non-Uniform Constraint Satisfaction15 In other words,the Dichotomy Conjecture says that the picture above de-scribes the complexity of non-uniform constraint-satisfaction problems CSP(B) for arbitrary structures B.The basis for the conjecture is not only the evi-dence from Boolean constraint satisfaction and undirected constraint satis-faction,but also from the seeming inability to carry out the diagonalization argument of[51]using the constraint-satisfaction machinery[27].The Dichotomy Conjecture inspired intensive research efforts that signif-icantly advanced our understanding of the complexity of non-uniform con-straint satisfaction.In particular,Bulatov confirmed two important cases of this conjecture.We say that a structure B=(B,R B1,...,R B m)is a3-element structure if B contains at most three element.We say that B is conserva-tive if all possible monadic relations on the universe included,that is,every non-empty subset of B is one of the relations R B i of B.Theorem1.7.[8,9]If B a3-element structure or a conservative structure, then either CSP(B)is in PTIME or CSP(B)is NP-complete.Moreover,in both cases the Tractability Classification Problem is decidable in poly-nomial time.In spite of the progress made,the Dichotomy Conjecture remains unre-solved in general.The research efforts towards this conjecture,however,have also resulted into the discovery of broad sufficient conditions for tractabil-ity and intractability of non-uniform constraint satisfaction that have pro-vided unifying explanations for numerous seemingly disparate tractability and intractability results and have also led to the discovery of new islands of tractability of CSP(B).These broad sufficient conditions are based on con-cepts and techniques from two different areas:universal algebra and logic.The approach via universal algebra yields sufficient conditions for tractabil-ity of CSP(B)in terms of closure properties of the relations in B under cer-tain functions on its universe B.Let R be a n-ary relation on a set B and f:B k→B a k-ary function.We say that R is closed under f,if whenever t1=(t11,t21,...,t n1),...,t k=(t1k,t2k,...,t n k)are k(not necessarily distinct) tuples in R,then the tuple(f(t11,...,t1k),f(t21,...,t2k),...,f(t n1,...,t n k))is also in R.We say that f:B k→B is a polymorphism of a structure B=(B,R1,...,R m)if each of the relations R j,1≤j≤m,is closed under f.It is easy to see that f is a polymorphism of B if and only if f is a homomorphism from B k to B,where B k is the k-th power of B.By definition, the k-th power B k is the structure(B k,R′1...,R′m)over the same vocabulary as B with universe B k and relations R′j,1≤j≤m,defined as follows:if R j is of arity n,then R′j(s1,...,s n)holds in B k if and only if R j(s i1,...,s i n) holds in B for1≤i≤n.We write Pol(B)for the set of all polymorphisms of B.As it turns out, the complexity of CSP(B)is intimately connected to the kinds of functions161Constraint Satisfactionthat Pol(B )contains.This connection was first unveiled in [29],and explored in depth by Jeavons and his collaborators;for a recent survey see [10].In particular,they showed that if Pol(B 1)=Pol(B 2)for two structures B 1and B 2(over finite vocabularies),then CSP(B 1)and CSP(B 2)are polynomially reducible to each other.Thus,the polymorphisms of a template B characterize the complexity of CSP(B ).The above mentioned dichotomy results for 3-element and conservative constraint satisfaction are based on a rather deep analysis of the appropriate sets of polymorphisms.1.5Monotone Monadic SNP and Non-UniformConstraint SatisfactionWe discussed earlier how non-uniform constraint satisfaction is related to the study of the expression complexity of conjunctive queries.We now show that it can also be viewed as the study of the data complexity of second-order logic.This will suggest a way to identify islands of tractability via logic.As described in Chapters ??and ??,existential second-order logic ESO defines,by Fagin’s Theorem,precisely the complexity class NP.The class SNP (for strict NP)[46,57]is a fragment of ESO,consisting of all existential second-order sentences with a universal first-order part,namely,sentences of the form (∃S ′)(∀x )Φ(x ,S,S ′),where Φis a first-order quantifier-free formula.We refer to the relations over the input vocabulary S as input relations ,while the relations over the quantified vocabulary S ′are referred to as existential re-lations .3-Sat is an example of an SNP problem.The input structure consists of four ternary relations C 0,C 1,C 2,C 3,on the universe {0,1},where C i cor-responds to a clause on three variables with the first i of them negated.There is a single existential monadic relation T describing a truth assignment.The condition that must be satisfied states that for all x 1,x 2,x 3,if C 0(x 1,x 2,x 3)then T (x 1)or T (x 2)or T (x 3),and similarly for the remaining C i by negating T (x j )if j ≤i .Formally,we can express 3-Sat with the SNP sentence:(∃T )(∀x 1,x 2,x 3)((C 0(x 1,x 2,x 3)→T (x 1)∨T (x 2)∨T (x 3))∧(C 1(x 1,x 2,x 3)→¬T (x 1)∨T (x 2)∨T (x 3))∧(C 2(x 1,x 2,x 3)→¬T (x 1)∨¬T (x 2)∨T (x 3))∧(C 3(x 1,x 2,x 3)→¬T (x 1)∨¬T (x 2)∨¬T (x 3))).It is easy to see that CSP(B )is in SNP for each structure B .For each ele-ment a in the universe of B ,we introduce an existentially quantified monadic relation T a ;intuitively,T a (x )indicates that a variable x has been assigned value a by the homomorphism.The sentence ϕB says that the sets T a cover all elements in the universe 3,and that the tuples in the input relations satisfy the constraints imposed by the structure B .Thus,if R (a 1,...,a n )does not hold in B ,then ϕB contains the conjunct ¬(R (x 1,...,x n )∧ n i =1T a i (x i )).For。

Lecture-09-Constraint_Satisfaction

Lecture-09-Constraint_Satisfaction
CS 561: Artificial Intelligence
Instructor:
TA:
Sofus A. Macskassy, macskass@
Harris Chiu (chichiu@), Wed 2:45-4:45pm, PHE 328 Penny Pan (beipan@), Fri 10am-noon, PHE 328
CS561 - Lecture 9 - Macskassy - Fall 2010
7
Constraint graph

Binary CSP: each constraint relates at most two variables Constraint graph: nodes are variables, arcs show constraints


Simple example of a formal representation language
Allows useful general-purpose algorithms with more power than standard search algorithms
3
CS561 - Lecture 9 - Macskassy - Fall 2010

General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem!
8
CS561 - Lecture 9 - Macskassy - Fall 2010

Continuous variables

分布式约束满足问题研究及其进展

分布式约束满足问题研究及其进展

ISSN 1000-9825, CODEN RUXUEW E-mail: jos@Journal of Software, Vol.17, No.10, October 2006, pp.2029−2039 DOI: 10.1360/jos172029 Tel/Fax: +86-10-62562563© 2006 by Journal of Softwar e. All rights reserved.∗分布式约束满足问题研究及其进展王秦辉, 陈恩红+, 王煦法(中国科学技术大学计算机科学技术系,安徽合肥 230027)Research and Development of Distributed Constraint Satisfaction ProblemsWANG Qin-Hui, CHEN En-Hong+, WANG Xu-Fa(Department of Computer Science and Technology, University of Science and Technology of China, Hefei 230027, China)+ Corresponding author: Phn: +86-551-3602824, Fax: +86-551-3603388, E-mail: cheneh@Wang QH, Chen EH, Wang XF. Research and development of distributed constraint satisfaction problems.Journal of Software, 2006,17(10):2029−2039. /1000-9825/17/2029.htmAbstract: With the rapid development and wide application of the Internet technology, many problems ofArtificial Intelligence, for example scheduling, planning, resource allocation etc., are formally distributed now,which turn into a kind of multi-agent system problems. Accordingly, the standard constraint satisfaction problemsturn into distributed constraint satisfaction problems, which become the general architecture for resolvingmulti-agent system. This paper first briefly introduces the basic concepts of distributed CSPs, and then summarizesthe basic and the improved algorithms. Their efficiency and performance are analyzed and the typical applicationsof distributed CSPs in recent years are discussed. Finally, this paper presents the extensions of the basicformalization and the research trends in this area. Recent related work indicates that the future work will focus onthe theoretical research to present the solid theoretical foundation for the practical problems.Key words: constraint satisfaction; distributed AI; multi-agent system; search; asynchronous摘 要: 近年来,随着网络技术的快速发展和广泛应用,人工智能领域中的诸多问题,如时序安排、计划编制、资源分配等,越来越多地以分布形式出现,从而形成一类多主体系统.相应地,求解该类问题的传统约束满足问题也发展为分布式约束满足问题,分布式约束满足已经成为多主体系统求解的一般框架.首先,简要介绍了分布式约束满足问题的基本概念,总结了该问题的基本算法及其改进算法,并对这些算法的效率和性能进行了比较分析.然后,讨论了近年来分布式约束满足问题的若干典型应用;最后,给出了分布式约束满足问题基本形式的扩展和今后的研究方向.分布式约束满足问题最新研究进展表明:今后的工作将着重于面向现实问题求解的理论研究,为实际应用提供坚实的理论基础.关键词: 约束满足;分布式人工智能;多主体系统;搜索;异步中图法分类号: TP301文献标识码: A自1974年Montanari在图像处理中首先提出了约束满足问题(constraint satisfaction problems,简称CSPs)[1]∗ Supported by the National Natural Science Foundation of China under Grant No.60573077 (国家自然科学基金); the Program forNew Century Excellent Talents in University of China under Grant No.NCET-05-0549 (新世纪优秀人才支持计划)Received 2006-03-09; Accepted 2006-05-082030 Journal of Software软件学报 V ol.17, No.10, October 2006以来,约束满足作为一种重要的求解方法在人工智能与计算机科学其他领域的很多问题中都得到了广泛的应用[2],从n皇后、图染色等经典问题到时序安排、计划编制、资源分配等大型应用问题,都可以形式化为约束满足问题进行求解.正因为在人工智能领域中的广泛适用,约束满足问题在理论、实验、应用上都得以深入研究,成为人工智能中很成功的问题解决范例之一.其相关成果一直是人工智能权威期刊《Artificial Intelligence》的热点,并有多个专题对此进行讨论;国内也有很多学者致力于约束满足问题的研究,主要的工作有约束程序理论、设计与应用的研究[3,4]、约束归纳逻辑程序设计等方面的研究[5,6],以及约束满足问题的求解研究[7−9]等等.约束满足问题是由一系列变量、变量相应的值域以及变量之间的约束关系组成,目标是为这些变量找到一组或多组满足所有约束关系的赋值.回溯搜索以及约束一致性检查两种基本思想和引入它们中的各种启发式方法构成了多种约束满足问题求解算法.随着硬件和网络技术的发展,分布式计算环境快速、广泛地在各个领域中得到应用,很多人工智能问题也越来越多地处于分布式计算环境下,使得分布式人工智能成为一个十分重要的研究领域,特别是关系到人工自治Agent间需要相互协调影响的分布式问题.如在多智能体系统(multi-agent system,简称MAS)中,处于同一环境下的Agent间通常存在着某种约束,此时,为各个Agent寻找一组满足它们之间约束的动作组合的分布式人工智能应用问题都可以看作是分布式约束满足问题(distributed CSPs).分布式约束满足问题是变量以及变量间的约束都分布在不同自治Agent中的约束满足问题,每个Agent控制一个或多个变量,并试图决定这些变量的值,一般在Agent内和Agent间都存在约束关系,对变量的赋值要满足所有这些约束.正因为不同的变量和约束是由不同的Agent控制,因此,在这种情形下,将所有Agent控制的变量及相关的约束等信息集中到一个Agent,再用传统的集中式约束满足算法进行求解往往是不充分或者是不可能的,有如下几点原因[10]:(1) 生成集中控制会带来额外开销.如类似于传感网络的约束满足问题很可能自然地分布在由一些同等Agent构成的集合中.这种情况下,对问题进行集中控制就需要增加不出现在原有结构中的额外元素.(2) 信息传递的开销.在很多情况下,约束由复杂的决策过程产生,这些过程是内在于Agent并且不可能被集中控制的.集中式算法需要获得这些约束关系就要承担信息传递的开销.(3) 隐私和安全的保证.在电子商务等情况中,常出现Agent之间的约束是不能泄露给竞争者甚至也不能泄露给集中控制的战略信息的情况.此时,隐私只能在分布式方法中得到很好的保护.(4) 面对失败的鲁棒性.集中控制求解时的失败可能是致命的;而在分布式方法中,一个Agent的失败并不是致命的,其他Agent可以在忽略已失败Agent的情况下找到问题的解.比如在传感网络和基于网络的应用中,当约束求解过程正在进行而参与者可能离开时,都会产生这些问题.从上述原因可以看出:此类分布式环境中的问题需要更有效的解决方法.随着人工智能领域协作式分布问题研究的深入,Yokoo等人在文献[11]中提出了分布式约束满足问题的框架和相应算法.作为一种新的技术,它特别适用于表示及求解规模大、难度高的组合问题.所以,分布式约束满足问题成为人工智能领域的一个研究热点.本文在文献[12]对分布式约束满足问题综述的基础上,不仅介绍了分布式约束满足的问题形式和一系列求解算法,还介绍了近年来在分布式约束满足问题基本形式上的扩展和多主体系统的应用.本文第1节介绍分布式约束满足问题的定义.第2节详述一系列求解分布式约束满足问题的算法,比如异步回溯、异步Weak-commitment搜索、分布式逃逸算法等.第3节介绍相应的应用.最后总结该问题上的一些扩展和类似的工作,如开放式、分布式局部约束满足、隐私安全性等.1 分布式约束满足1.1 约束满足问题约束满足问题是在一定的值域范围内为所有变量寻找满足它们彼此间约束关系的赋值的问题,由变量、变量的值域和变量之间的约束组成.定义1(约束满足问题). 约束满足问题可以形式化为一个约束网[13],由变量的集合、每个变量的值域的集合以及变量间的约束关系的集合来定义,表示为三元组(V,D,C),其中:王秦辉等:分布式约束满足问题研究及其进展2031V是变量的集合{v1,…,v n};D是所有变量的值域的集合,D={D1,…,D n}, D i是变量v i的所有可能取值的有限域;C是变量之间的约束关系的集合C={C1,…,C m},其中每个约束包含一个V的子集{v i,…,v j}和一个约束关系R⊆D i×…×D j.约束满足方法是一种有效的问题求解方法,它为每个变量在其值域中寻找一个赋值,使得所有约束被满足.定义2(约束满足问题的解). 约束满足问题的解是分配给问题中所有变量的一组不违反任何约束的赋值.也即一组对所有变量的赋值S(v1,…,v n)={d1∈D1,…,d n∈D n},∀C r∈C都有S(v ri,…,v rj)={d ri,…,d rj}∈R r.例如,n皇后问题就是典型的约束满足问题.该问题描述为要在n×n的棋盘上摆放n个皇后,使得每一行、每一列和每条对角线上只能有一个皇后存在.图1是4皇后问题的示例以及相应的约束满足问题.(a) (b) (d)Fig.1 4 queens constraint satisfaction problem图1 4皇后及相应的约束满足问题图1(a)表示在4×4的棋盘上放置4个皇后Q1~Q4,即为变量集合;图1(b)表示任意行、列、对角线上不能同时有两个皇后,即为约束关系;图1(c)是相对应的约束满足关系网;图1(d)是该问题的一个解.1.2 分布式约束满足问题分布式约束满足问题是变量和约束都分布在不同自治Agent中的约束满足问题.在约束满足问题定义的基础上,可如下定义分布式约束满足问题:定义3(分布式约束满足问题). n个Agent表示为A1,A2,…,A n,m个变量为v1,v2,…,v m,m个变量的值域为D1, D2,…,D m,变量间的约束仍用C表示;每个Agent有一个或多个变量,每个变量v j属于一个A i,表示为belongs(v j, A i);变量间的约束关系分布在Agent内或Agent之间,当A l知道约束关系C k时,表示为Known(C k,A l).分布在Agent内的约束称为局部约束,而Agent间的约束称为全局约束,局部约束可以通过Agent的计算来处理,全局约束不仅需要Agent的计算,更需要Agent间的通信来处理,因此需要如下的通信模式假设: 假设1. Agent间的通信通过传递消息完成,当且仅当一个Agent知道对方地址时才能够传递消息给其他Agent.假设2. 传递消息的延时是随机但有限的,任何一对Agent间消息接收的顺序与消息发送的顺序是一致的.假设3. 每个Agent只知道整个问题的部分信息.分布式约束满足中的Agent与多智能体系统(MAS)中的Agent有着细小的差别[14],分布式约束满足中的Agent是遵从协作机制来执行决策行为的计算实体;MAS中的Agent自治地决定是否遵从特定的协作机制,并能以结构化的语义消息交换形式与其他Agent进行通信.在将MAS形式化为分布式约束满足问题进行求解时,并不考虑这些区别.每一个Agent负责一些变量并决定它们的值,因为还存在着Agent间的内在约束,所以,赋值必须满足这些约束.分布式约束满足问题的解的形式化定义为:定义4(分布式约束满足问题的解). 当且仅当满足下述条件时,分布式约束满足问题找到了解:∀A i,∀v j存在关系belongs(v j,A i),当v j的赋值是d j∈D j时,∀C k,∀A l,Known(C k,A l)都有C k被满足.也即此时对问题中所有变量的赋值满足Agent间及Agent内的所有约束.2032 Journal of Software 软件学报 V ol.17, No.10, October 2006图2是一个分布式约束满足问题的示例.该问题为分布式图染色问题,从黑、白、灰这3种颜色中选一种分配给Agent 中的节点变量,使得互相连接的节点颜色不同.图中每个Agent 都各有3个变量,变量之间的边就表示彼此间存在着约束关系,该问题不仅Agent 内而且Agent 间都存在着约束关系.(a) (b) (c)Fig.2 Example of distributed constraint satisfaction problem图2 分布式约束满足问题示例图2(a)表示该问题的约束关系网;图2(b)为随机分配着色的初始状态;图2(c)是该问题的一个解.1.3 分布式约束满足与并行/分布式计算的区别分布式约束满足问题看起来与求解约束满足问题的并行/分布式方法[15,16]虽然很相似,但它们从根本上是不同的.并行/分布式方法应用到约束满足问题求解中的目的是为了提高问题的求解效率,针对不同的约束满足问题可以选择任何一种合适的并行/分布式计算机体系结构将问题分而治之,取得较高的求解效率.而在分布式约束满足中,问题的变量和约束等相关信息从问题给定时就既定地分布于各个自治Agent 中,所以,研究的出发点是如何在这种固有的情形下有效地获得问题的解.比如一个大规模的n 皇后问题,可以利用分布式并行计算获得更快的求解速度.而对应到分布式的n 皇后问题,则是很多个不同的Agent 拥有数量不同的皇后,通过自我决策和Agent 间的通信协作来共同达到问题的解.2 求解分布式约束满足问题的算法在分布式约束满足问题提出的同时,Yokoo 就在文献[11]中提出了异步回溯算法.近些年来,其他的分布式约束满足求解算法也得到了进一步的研究,特别是异步Weak-commitment 搜索[17,18]和分布式逃逸算法[19]等.这些算法基本上是由约束满足问题的求解算法而来,是这些传统算法的分布式扩展.但是,因为分布式约束满足问题中Agent 之间也存在着约束关系,所以,Agent 间需要通信是与传统算法的最大区别.分布式约束满足算法有两种最基本的消息需要通信,分别是ok ?和nogood [11].定义5(ok ?消息). ok ?是指Agent 将当前的赋值信息传递给相邻Agent 的消息.定义6(nogood 消息). nogood 是用来传递约束是否发生冲突而产生新约束的消息.在文献[12]中,对各种算法的描述都做了如下假设:(1) 每个Agent 只控制一个变量;(2) 所有的约束都是二元的;(3) 每个Agent 知道所有和自己变量相关的约束.因此,可以不加区分地使用相同标识v i 表示一个Agent 及其变量,用约束网中的有向边表示约束关系,该有向边由发送消息Agent 指向接收消息Agent.对假设2和假设3都可以自然地扩展到一般情形.下面分别介绍基于回溯的异步回溯算法、基于优化迭代的分布式逃逸算法和基于混合算法的异步Weak-commitment 算法.2.1 异步回溯(AB :Asynchronous backtracking )异步回溯算法是由求解约束满足问题的回溯算法而来.所不同的是,异步回溯算法是分布式的、异步的.在异步回溯算法中,每个Agent 都有一个优先顺序,该优先顺序是预先定义好的,一般由Agent 标识的字母顺序来王秦辉等:分布式约束满足问题研究及其进展2033决定,比如,按降序或升序来决定Agent的优先序的高低.在该算法中,每个Agent除了要发送接受ok?和nogood 消息以外,还要维护一个agent_view,这是用来记录其他Agent的当前赋值的.当一个Agent接收到ok?消息时,则检查其赋值与优先顺序高的Agent的当前赋值是否满足约束关系,如果不满足约束关系产生冲突而不一致就改变自己的赋值;如果该Agent值域中没有能与高优先序Agent的赋值相一致的值,就产生一个新的约束关系(也就是nogood),并且将nogood传递给高优先序Agent,这样,高优先序Agent就可以改变自己的赋值.必须注意到:如果Agent不断地改变它们的赋值而不能达到一个稳定状态,那么它们就处于一种无限处理循环,当一个Agent的赋值导致其他Agent改变赋值而最终影响到自己时就可能产生这种无限循环.为了避免这种情况的发生,在算法中,按照标识的字母序为每个Agent定义了优先顺序,ok?只能从高优先序Agent发送给低优先序Agent.当产生nogood时,也是nogood中的优先序最低的Agent接收到nogood消息.另外,每个Agent的行动都是同时异步发生的,而且Agent间的通信是通过消息传递来进行的,所以,agent_view中可能包含有已经无用的信息.因此,每个Agent都需要产生新的nogood进行通信,新nogood的接收方也必须检查在自己的agent_view的基础上与此nogood是否有冲突.因为算法中最高优先序的Agent不会陷入无限处理循环中,文献[18]用归纳法证明了该算法是具备完全性的,也即:如果问题有解存在,那么一定能找到这个解;如果没有解存在,那么算法也会终止,不会陷入无限循环.近年来,有很多工作都对异步回溯算法进行了改进.在对算法进行扩展时,文献[20]采用了Agent的动态重排序;文献[21]引入了一致性维护;文献[22]提出了不存储nogood消息的分布式回溯算法.这些算法与基本的异步回溯算法相比只是存储nogood消息的方式不同,它们都需要在未相连的Agent之间添加通信连接来检测已经无用的消息.而文献[23]中提出了一种新的异步回溯算法来避免在初始未相连的Agent之间动态地增添新的约束,这样就可以避免将一些信息传递给不需要知道的Agent,从而提高效率.文献[24]从另一个角度提出了如何利用值聚集来减少信息阻塞以及如何利用弧一致维护来提高异步分布式下问题求解的有效性.2.2 异步Weak-Commitment搜索(AWS:Asynchronous weak-commitment search)异步回溯算法的局限在于Agent的优先顺序是预先定义好的,是静态的.如果高优先序Agent的赋值选择得不好,那么,低优先序Agent就要进行穷尽查找来修正不利的赋值.异步Weak-commitment搜索算法[17,18]的两个基本思想是:为了减少不利赋值的风险而引入了最小冲突启发;更进一步地,Agent的优先级顺序是可以动态改变的,这样,不利赋值不需要穷尽搜索就能够得到更正.最小冲突启发是指Agent选择值域中那些与其他Agent的赋值产生最少冲突的值作为自己的赋值.而为了使Agent的优先级顺序能够动态改变,特别地为Agent引入了优先值,优先值是非负整数,优先值大的Agent具有较高的优先顺序,优先值相等的Agent的优先顺序由它们所标识的字母序来决定.初始时,Agent的优先值均为0,当Agent的赋值与约束发生冲突而不一致时,该Agent的优先值就变为相邻Agent中的最大优先值再加1.与异步回溯算法相比,异步Weak-commitment搜索算法的不同在于:(1) 异步回溯中每个Agent只将变量赋值发送给约束相关的低优先级Agent;而异步Weak-commitment搜索中每个Agent将变量赋值发送给约束相关的所有Agent,无论优先级的高低;(2)ok?消息不仅用来传递Agent的当前赋值,还用来传递Agent的优先值;(3) 如果当前的赋值与agent_view不一致,则Agent用最小冲突启发来改变赋值;(4) 如果Agent不能找到与自己的agent_view一致的赋值,就发送nogood消息给其他Agent,同时改变自己的优先值.如果Agent不能生成新的nogood,那么就不改变自己的优先值,并等待下一条消息.第4步的过程是保证算法的完全性所必需的.因为优先值的改变只有在新的nogood产生时才发生,而可能的nogood的数量是有限的,优先值不可能无限地改变,所以到了某个时间之后,优先值就稳定下来,此后,过程就与异步回溯算法一样,故而算法是完全的.为了保证算法的完全性,Agent要记录所有目前已知的nogood,实际操作时,可以限制记录nogood的数目,比如每个Agent只记录固定数目的最近发生的nogood消息.正如前面所提到的假设,这些算法中的Agent都只含有一个变量,对于解决Agent含有多个变量的问题,无论是采用先让Agent找到自己局部问题的所有解后再将问题重新形式化为分布式约束满足问题来求解,还是让2034 Journal of Software软件学报 V ol.17, No.10, October 2006Agent为每个局部变量生成一个虚拟Agent再来模拟这些Agent的动作来求解,对大规模问题而言,既没有效率也不能扩展.文献[25]对异步Weak-commitment搜索算法进行了扩展,利用变量顺序来解决多个局部变量的问题,称为Multi-AWS.它的特点是Agent按顺序来改变自己变量的值,当某个变量不存在满足所有与高优先序的变量有关的约束时,就增加该变量的优先值.不断反复该过程,当Agent中所有局部变量都与高优先序变量满足约束时,就传递值改变消息给相关的Agent.2.3 分布式逃逸(DB:Distributed breakout)在最小冲突回溯等约束满足算法中的爬山(hill-climbing)搜索策略,有时会使求解过程陷入局部最小(local-minima)状态.local-minima状态就是一些约束没有被满足从而出现了冲突,但是这些冲突的数目不能通过单独改变任何一个变量的值来减少.文献[26]中提出的逃逸算法是一种跳出local-minima状态的方法,算法中为每个约束定义了权值,所有冲突约束的权值总和作为一个评估值.当陷入local-minima状态时,逃逸算法增加当前状态中冲突约束的权值,使得当前状态的评估值高于其他邻接的状态,从而跳出local-minima状态,开始新的搜索.文献[19]在此基础上通过以下两个步骤来实现分布式逃逸:(1) 始终保证评估值是逐步提高的:相邻的Agent对可能会提高的评估值进行交流,只有能够最大提高评估值的Agent才有权改变自己的值.如果两个Agent不相邻,那么它们有可能同时改变自己的值;(2) 与检测整个Agent是否陷入local-minima不同的是,每个Agent检测其是否处于quasi-local-minima状态,这是比local-minima要弱一些的条件,并且能够通过局部通信而检测到.定义7(Agent A i处于quasi-local-minimum状态). A i的赋值使部分约束产生冲突,并且A i和所有A i邻居的可能提高值均为0.在分布式逃逸算法中,相邻的Agent之间有两种消息的通信:ok?和improve. improve消息用来对可能提高的评估值进行通信,Agent在整个过程中处于wait_ok?和wait_improve两种交替状态.分布式逃逸算法有可能陷入无限循环当中,因而不能保证算法的完全性.文献[27]在对分布式逃逸算法进行扩展时,不仅提出了解决Agent有多个局部变量的Multi-DB算法,还对此算法引入了两种随机方式.一种是利用了随机跳出技术的Multi-DB+算法,另一种是在Multi-DB+中又引入随机行走的Multi-DB++算法.这些算法比其他异步方法有更好的扩展性,但有时也会有更差的性能.2.4 几种算法的比较上面介绍了几种求解分布式约束满足问题的基本算法,这些算法有各自的特点和适用性,也各有优点和局限性,表1是就上述算法在完全性及解决多局部变量方面的一个定性比较.Table 1Comparison of algorithms for solving distributed CSPs表1几种基本分布式约束满足问题求解算法的定性比较Algorithm AB AWS Multi-AWS DB Multi-DBNo NoCompleteness Yes Yes YesMulti local variables No No Yes No Yes文献[12]对基本的异步回溯(AB)、异步Weak-commitment(AWS)和分布式逃逸(DB)算法进行了性能比较.通过离散的事件模拟来评估算法的效率,其中每个Agent维护自己的模拟时钟,只要Agent执行一个计算周期,其时间就增加一个模拟时间单元.一个计算周期包括读取所有消息、执行局部计算和发送消息.假设一个消息在时间t发布,则对接收者来说,在时间t+1时可用.最后,通过解决问题所需的计算周期数量来分析算法的性能.表2是用分布式图染色问题来评测的结果,其中:Agent(变量)的数目n=60,90和120;约束的数量为m=n×2,可能的颜色数目为3.总共生成10个不同的问题,对每个问题执行10次不同的初始赋值,并且限制周期最大为1000,超过后就终止算法.表中列出了算法求解所需的平均周期和求解成功的比例.明显地,AWS算法要优于AB算法,因为在AWS算法中,不需要执行穷尽查找就能修正错误的赋值.在表3和表4比较AWS与DB算法时,Agent(变量)的数目为n=90,120和150,约束的数量分别为m=n×2王秦辉等:分布式约束满足问题研究及其进展2035和m=n×2.7两种情况,可能的颜色数仍然为3.当m=n×2时,可认为Agent间的约束是比较稀疏的;而当m=n×2.7时,则被认为是能够产生阶段跳跃的临界状态[28].Table 2 Comparison between AB and AWS表2算法AB和AWS的比较nAlgorithm60 90 120Ratio (%) 13 0 0ABCycles 917.4 --Ratio (%) 100 100 100AWSCycles 59.4 70.1 106.4Table 3Comparison between DB and AWS (m=n×2)表3算法DB和AWS的比较(m=n×2)nAlgorithm90 120 150Ratio (%) 100 100 100DBCycles 150.8 210.1 278.8Ratio (%) 100 100 100AWSCycles 70.1 106.4 159.2Table 4Comparison between DB and AWS (m=n×2.7)表4算法DB和AWS的比较(m=n×2.7)nAlgorithm90 120 150Ratio (%) 100 100 100DBCycles 517.1 866.4 1175.5Ratio (%) 97 65 29AWSCycles 1869.6 6428.4 8249.5从表3和表4中可以看出:当问题为临界困难时,DB算法要优于AWS算法.而对于一般情形,AWS算法要优于DB算法.因为在DB算法中,每个模式(wait_ok?或者wait_improve)都需要一个周期,所以每个Agent在两个周期内至多只能改变一次赋值;而在AWS算法中,每个Agent在每个周期内都可以改变赋值.如前所述,近年来的很多工作都对这些基本算法进行了改进或者扩展,在性能和效率方面也有各自的特点.文献[20]中的实验表明:对Agent进行动态重排序的ABTR(ABT with asynchronous reordering)算法的平均性能要优于AB算法,说明额外增加动态重排序的启发式消息实际上是可以提高算法效率的.文献[24]通过实验表明:采用值聚集的AAS(asynchronous aggregation search)算法的效果要稍好一些.虽然在查找第一个解时,不利用值聚集的效果会更好,但是如果解不存在,那么AAS的性能总是要优于不采用值聚集的算法,因为此时需要扩展到整个搜索空间,AAS可以减少消息序列,也就是减少存储nogoods消息的数目.更进一步地,使用了bound- consistency一致维护技术的MHDC(maintaining hierarchical distributed consistency)算法在实验中的整体性能要比AAS有很大的提高.通过图染色实验,文献[25]比较了算法Multi-AWS,AWS-AP(Agent priority)和Single-AWS,对于Agent有多个变量的情况,Multi-AWS算法在执行周期以及一致性检查数目上都要优于其他两种算法,而且随着Agent或变量的增多,其性能就越优于AWS-AP算法和Single-AWS算法.这是因为在解决Agent有多个变量的问题时,AWS-AP算法和Single-AWS算法需要增加额外的虚拟Agents来将多局部变量分布化,这样就增加了Agents 间的通信,从而使性能降低.文献[27]首先比较了Multi-DB和Multi-AWS算法.Multi-DB算法随着变量数目的增多,效率会越来越优于Multi-AWS算法,在很多情形下会有至少1个数量级的提高,但是成功率却较低.原因是由于Multi-DB算法在查找过程中固有的确定性使算法缺少了随机性.对于实验中Multi-DB++算法的效率优于Multi-DB算法,可以得出结论:多Agent搜索进程中的停滞可以通过添加随机行走来避免.。

人工智能05约束满足问题

人工智能05约束满足问题

CSP:
state is defined by goal test is a set of
vcaorniasbtrlaeisnXtsi
wspitehcivfayilnugesafllroowmadbolemcaoimn(bin值at域ion)s Doif
values
for subsets of variables
Binary CSP: 每个约束与2个变量有关 约束图: 节点是变量, 边是约束
General-purpose CSP algorithms(通用CSP算法) use the graph structure to speed up search.
E.g., Tasmania is an independent subproblem!
每个约束包括一些变量的子集,并指定这些子集的值之间允许进行的
合并
Simple example of a formal representation language(形式化表示方法) Allows useful general-purpose(通用的,而不是问题特定的) algorithms with more power than standard search algorithms
Minimum remaining values
Minimum remaining values 最少剩余值(MRV): 选择“合法”取值最少的变量
Why min rather than max? 被称为“最受约束变量” 或“失败优先”启发式
Degree heuristic(度启发式)
在MRV无法抉择时启动度启发式 度启发式:
Depth-first search for CSPs with single-variable assignments is called backtracking search

A parallelization scheme based on work stealing for a class of sat solvers

A parallelization scheme based on work stealing for a class of sat solvers

1. Introduction Consider a propositional formula F in Conjunctive Normal Form (CNF) on a set of n boolean variables {x1 , x2 , · · · , xn }. A literal l is a variable xi or its negation x ¯i , a clause c is a logical or of some literals (e.g. (x1 ∨ x ¯2 ∨ x3 )) and a formula F is a logical and of clauses. A k-SAT problem is a problem where there are k literals per clause. The satisfiability (SAT) problem consists in finding an assignment of truth value (1 for true and 0 for f alse) to variables such that F is true. If such an assignment exists, then F is said satisfiable, otherwise, F is said unsatisfiable. SAT is a specific kind of finite-domain Constraint Satisfaction Problem (CSP) and it is the first known N P -complete problem [4] (3-SAT is its smallest N P -complete sub-problem). Many problems in various domains can naturally be encoded into SAT then solved by a SAT solver. Encoding a real-world problem into SAT is generally easier than writing a specialized algorithm for the problem. Moreover, some problems can be solved more efficiently by a SAT solver (after encoding) than by the specialized algorithm. For example, by using propositional reasoning, many problems like quasigroup completion problems [33, 35], planning [22, 21] and hardware

加州伯克利CS188人工智能导论全部笔记=n5

加州伯克利CS188人工智能导论全部笔记=n5

CS188Introduction to Artificial IntelligenceSpring2019Note5 These lecture notes are heavily based on notes originally written by Nikhil Sharma.Constraint Satisfaction ProblemsIn the previous note,we learned how tofind optimal solutions to search problems,a type of planning problem.Now,we’ll learn about solving a related class of problems,constraint satisfaction problems (CSPs).Unlike search problems,CSPs are a type of identification problem,problems in which we must simply identify whether a state is a goal state or not,with no regard to how we arrive at that goal.CSPs are defined by three factors:1.Variables-CSPs possess a set of N variables X1,...,X N that can each take on a single value from somedefined set of values.2.Domain-A set{x1,...,x d}representing all possible values that a CSP variable can take on.3.Constraints-Constraints define restrictions on the values of variables,potentially with regard to othervariables.Consider the N-queens identification problem:given an N×N chessboard,can wefind a configuration in which to place N queens on the board such that no two queens attack each another?We can formulate this problem as a CSP as follows:1.Variables-X i j,with0≤i,j<N.Each X i j represents a grid position on our N×N chessboard,with iand j specifying the row and column number respectively.2.Domain-{0,1}.Each X i j can take on either the value0or1,a boolean value representing theexistence of a queen at position(i,j)on the board.3.Constraints-•∀i,j,k(X i j,X ik)∈{(0,0),(0,1),(1,0)}.This constraint states that if two variables have the samevalue for i,only one of them can take on a value of1.This effectively encapsulates the conditionthat no two queens can be in the same row.•∀i,j,k(X i j,X k j)∈{(0,0),(0,1),(1,0)}.Almost identically to the previous constraint,this con-straint states that if two variables have the same value for j,only one of them can take on a valueof1,encapsulating the condition that no two queens can be in the same column.•∀i,j,k(X i j,X i+k,j+k)∈{(0,0),(0,1),(1,0)}.With similar reasoning as above,we can see thatthis constraint and the next represent the conditions that no two queens can be in the same majoror minor diagonals,respectively.•∀i,j,k(X i j,X i+k,j−k)∈{(0,0),(0,1),(1,0)}.X i j=N.This constraint states that we must have exactly N grid positions marked with a1,•∑i,jand all others marked with a0,capturing the requirement that there are exactly N queens on theboard.Constraint satisfaction problems are NP-hard,which loosely means that there exists no known algorithm for finding solutions to them in polynomial time.Given a problem with N variables with domain of size O(d)for each variable,there are O(d N)possible assignments,exponential in the number of variables.We can often get around this caveat by formulating CSPs as search problems,defining states as partial assignments (variable assignments to CSPs where some variables have been assigned values while others have not). Correspondingly,the successor function for a CSP state outputs all states with one new variable assigned, and the goal test verifies all variables are assigned and all constraints are satisfied in the state it’s testing. Constraint satisfaction problems tend to have significantly more structure than traditional search problems, and we can exploit this structure by combining the above formulation with appropriate heuristics to hone in on solutions in a feasible amount of time.Constraint GraphsLet’s introduce a second CSP example:map coloring.Map coloring solves the problem where we’re given a set of colors and must color a map such that no two adjacent states or regions have the same color.Constraint satisfaction problems are often represented as constraint graphs,where nodes represent variables and edges represent constraints between them.There are many different types of constraints,and each is handled slightly differently:•Unary Constraints-Unary constraints involve a single variable in the CSP.They are not represented in constraint graphs,instead simply being used to prune the domain of the variable they constrain when necessary.•Binary Constraints-Binary constraints involve two variables.They’re represented in constraint graphs as traditional graph edges.•Higher-order Constraints-Constraints involving three or more variables can also be represented with edges in a CSP graph,they just look slightly unconventional.Consider map coloring the map of Australia:The constraints in this problem are simply that no two adjacent states can be the same color.As a result,by drawing an edge between every pair of states that are adjacent to one another,we can generate the constraint graph for the map coloring of Australia as follows:The value of constraint graphs is that we can use them to extract valuable information about the structure of the CSPs we are solving.By analyzing the graph of a CSP,we can determine things about it like whether it’s sparsely or densely connected/constrained and whether or not it’s tree-structured.We’ll cover this more in depth as we discuss solving constraint satisfaction problems in more detail.Solving Constraint Satisfaction ProblemsConstraint satisfaction problems are traditionally solved using a search algorithm known as backtracking search.Backtracking search is an optimization on depthfirst search used specifically for the problem of constraint satisfaction,with improvements coming from two main principles:1.Fix an ordering for variables,and select values for variables in this order.Because assignments arecommutative(e.g.assigning WA=Red,NT=Green is identical to NT=Green,WA=Red),this is valid.2.When selecting values for a variable,only select values that don’t conflict with any previously as-signed values.If no such values exist,backtrack and return to the previous variable,changing its value.The pseudocode for how recursive backtracking works is presented below:For a visualization of how this process works,consider the partial search trees for both depthfirst search and backtracking search in map coloring:Note how DFS regretfully colors everything red before ever realizing the need for change,and even then doesn’t move too far in the right direction towards a solution.On the other hand,backtracking search only assigns a value to a variable if that value violates no constraints,leading to a significantly less backtracking. Though backtracking search is a vast improvement over the brute-forcing of depthfirst search,we can get more gains in speed still with further improvements throughfiltering,variable/value ordering,and structural explotation.FilteringThefirst improvement to CSP performance we’ll consider isfiltering,which checks if we can prune the domains of unassigned variables ahead of time by removing values we know will result in backtracking.A naïve method forfiltering is forward checking,which whenever a value is assigned to a variable X i, prunes the domains of unassigned variables that share a constraint with X i that would violate the constraint if assigned.Whenever a new variable is assigned,we can run forward checking and prune the domains of unassigned variables adjacent to the newly assigned variable in the constraint graph.Consider our map coloring example,with unassigned variables and their potential values:Note how as we assign WA=red and then Q=green,the size of the domains for NT,NSW,and SA(states adjacent to WA,Q,or both)decrease in size as values are eliminated.The idea of forward checking can be generalized into the principle of arc consistency.For arc consistency,we interpret each undirected edge of the constraint graph for a CSP as two directed edges pointing in opposite directions.Each of these directed edges is called an arc.The arc consistency algorithm works as follows:•Begin by storing all arcs in the constraint graph for the CSP in a queue Q.•Iteratively remove arcs from Q and enforce the condition that in each removed arc X i−→X j,for every remaining value v for the tail variable X i,there is at least one remaining value w for the head variable X j such that X i=v,X j=w does not violate any constraints.If some value v for X i would not work with any of the remaining values for X j,we remove v from the set of possible values for X i.•If at least one value is removed for X i when enforcing arc consistency for an arc X i−→X j,add arcs of the form X k−→X i to Q,for all unassigned variables X k.If an arc X k−→X i is already in Q during this step,it doesn’t need to be added again.•Continue until Q is empty,or the domain of some variable is empty and triggers a backtrack.The arc consistency algorithm is typically not the most intuitive,so let’s walk through a quick example with map coloring:We begin by adding all arcs between unassigned variables sharing a constraint to a queue Q,which gives us Q=[SA→V,V→SA,SA→NSW,NSW→SA,SA→NT,NT→SA,V→NSW,NSW→V]For ourfirst arc,SA→V,we see that for every value in the domain of SA,{blue},there is at least one value in the domain of V,{red,green,blue},that violates no constraints,and so no values need to be pruned from SA’s domain.However,for our next arc V→SA,if we set V=blue we see that SA will have no remaining values that violate no constraints,and so we prune blue from V’s domain.Because we pruned a value from the domain of V,we need to enqueue all arcs with V at the head-SA→V, NSW→V.Since NSW→V is already in Q,we only need to add SA→V,leaving us with our updated queueQ=[SA→NSW,NSW→SA,SA→NT,NT→SA,V→NSW,NSW→V,SA→V]We can continue this process until we eventually remove the arc SA→NT from Q.Enforcing arc consis-tency on this arc removes blue from SA’s domain,leaving it empty and triggering a backtrack.Note that the arc NSW→SA appears before SA→NT in Q and that enforcing consistency on this arc removes blue from the domain of NSW.Arc consistency is typically implemented with the AC-3algorithm(Arc Consistency Algorithm#3),for which the pseudocode is as follows:The AC-3algorithm has a worst case time complexity of O(ed3),where e is the number of arcs(directed edges)and d is the size of the largest domain.Overall,arc consistency is more holistic of a domain pruning technique than forward checking and leads to fewer backtracks,but requires running significantly more computation in order to enforce.Accordingly,it’s important to take into account this tradeoff when deciding whichfiltering technique to implement for the CSP you’re attempting to solve.As an interesting parting note about consistency,arc consistency is a subset of a more generalized notion of consistency known as k-consistency,which when enforced guarantees that for any set of k nodes in the CSP,a consistent assignment to any subset of k−1nodes guarantees that the k th node will have at least one consistent value.This idea can be further extended through the idea of strong k-consistency.A graph that is strong k-consistent possesses the property that any subset of k nodes is not only k-consistent but also k−1,k−2,...,1consistent as well.Not surprisingly,imposing a higher degree of consistency on a CSP is more expensive to compute.Under this generalized definition for consistency,we can see that arc consistency is equivalent to2-consistency.OrderingWe’ve delineated that when solving a CSP,wefix some ordering for both the variables and values involved. In practice,it’s often much more effective to compute the next variable and corresponding value"on thefly" with two broad principles,minimum remaining values and least constraining value:•Minimum Remaining Values(MRV)-When selecting which variable to assign next,using an MRV policy chooses whichever unassigned variable has the fewest valid remaining values(the most con-strained variable).This is intuitive in the sense that the most constrained variable is most likely to run out of possible values and result in backtracking if left unassigned,and so it’s best to assign a value to it sooner than later.•Least Constraining Value(LCV)-Similarly,when selecting which value to assign next,a good policy to implement is to select the value that prunes the fewest values from the domains of the remain-ing unassigned values.Notably,this requires additional computation(e.g.rerunning arc consis-tency/forward checking or otherfiltering methods for each value tofind the LCV),but can still yieldspeed gains depending on usage.StructureAfinal class of improvements to solving constraint satisfaction problems are those that exploit their struc-ture.In particular,if we’re trying to solve a tree-structured CSP(one that has no loops in its constraint graph),we can reduce the runtime forfinding a solution from O(d N)all the way to O(nd2),linear in the number of variables.This can be done with the tree-structured CSP algorithm,outlined below:•First,pick an arbitrary node in the constraint graph for the CSP to serve as the root of the tree(it doesn’t matter which one because basic graph theory tells us any node of a tree can serve as a root).•Convert all undirected edges in the tree to directed edges that point away from the root.Then linearize (or topologically sort)the resulting directed acyclic graph.In simple terms,this just means order the nodes of the graph such that all edges point rightwards.Noting that we select node A to be our root and direct all edges to point away from A,this process results in the following conversion for the CSP presented below:•Perform a backwards pass of arc consistency.Iterating from i=n down to i=2,enforce arc con-sistency for all arcs Parent(X i)−→X i.For the linearized CSP from above,this domain pruning will eliminate a few values,leaving us with the following:•Finally,perform a forward assignment.Starting from X1and going to X n,assign each X i a value consistent with that of its parent.Because we’ve enforced arc consistency on all of these arcs,no matter what value we select for any node,we know that its children will each all have at least one consistent value.Hence,this iterative assignment guarantees a correct solution,a fact which can be proven inductively without difficulty.The tree structured algorithm can be extended to CSPs that are reasonably close to being tree-structured with cutset conditioning.Cutset conditioning involvesfirstfinding the smallest subset of variables in a constraint graph such that their removal results in a tree(such a subset is known as a cutset for the graph). For example,in our map coloring example,South Australia(SA)is the smallest possible cutset:Once the smallest cutset is found,we assign all variables in it and prune the domains of all neighboring nodes.What’s left is a tree-structured CSP,upon which we can solve with the tree-structured CSP algorithm from above!The initial assignment to a cutset of size c may leave the resulting tree-structured CSP(s)with no valid solution after pruning,so we may still need to backrack up to d c times.Since removal of the cutset leaves us with a tree-structured CSP with(n−c)variables,we know this can be solved(or determined that no solution exists)in O((n−c)d2).Hence,the runtime of cutset conditioning on a general CSP is O(d c(n−c)d2),very good for small c.Local SearchAs afinal topic of interest,backtracking search is not the only algorithm that exists for solving constraint satisfaction problems.Another widely used algorithm is local search,for which the idea is childishly simple but remarkably useful.Local search works by iterative improvement-start with some random assignment to values then iteratively select a random conflicted variable and reassign its value to the one that violates the fewest constraints until no more constraint violations exist(a policy known as the min-conflicts heuristic). Under such a policy,constraint satisfaction problems like N-queens becomes both very time efficient and space efficient to solve.For example,in following example with4queens,we arrive at a solution after only2iterations:for N-queens with arbitrarily large N,but also for any randomly generated CSP!However,despite theseadvantages,local search is both incomplete and suboptimal and so won’t necessarily converge to an optimal solution.Additionally,there is a critical ratio around which using local search becomes extremely expensive:SummaryIt’s important to remember that constraint satisfaction problems in general do not have an efficient algorithm which solves them in polynomial time with respect to the number of variables involved.However,by using various heuristics,we can oftenfind solutions in an acceptable amount of time:•Filtering-Filtering handles pruning the domains of unassigned variables ahead of time to prevent unnecessary backtracking.The two importantfiltering techniques we’ve covered are forward checking and arc consistency.•Ordering-Ordering handles selection of which variable or value to assign next to make backtracking as unlikely as possible.For variable selection,we learned about a MRV policy and for value selection we learned about a LCV policy.•Structure-If a CSP is tree-structured or close to tree-structured,we can run the tree-structured CSP algorithm on it to derive a solution in linear time.Similarly,if a CSP is close to tree structured,we can use cutset conditioning to transform the CSP into one or more independent tree-structured CSPs and solve each of these separately.加入“知识星球 行业与管理资源”库,每日免费获取报告1、每月分享1000+份最新行业报告(涵盖科技、金融、教育、互联网、房地产、生物制药、医疗健康等最新行业)2、每月分享500+企业咨询管理文件(涵盖国内外著名咨询公司相关管理方案,企业运营制度等)3、每月分享500+科技类论文或者大师课件、笔记。

Neighborhood-based variable ordering heuristics for the constraint satisfaction problem

Neighborhood-based variable ordering heuristics for the constraint satisfaction problem

2 Preamble
2.1 De nitions and notations
A constraint network is de ned by a set of variables, each taking values in its nite domain, and a set of constraints restricting the possible combinations of values between variables. For simplicity we restrict our attention here to binary constraint networks, where the constraints involve two variables.1 Binary constraints are binary relations. If a variable i has a domain of possible values ( i ) and a variable j has a domain ( j ), the constraint on i and j , , which speci es the allowed pairs of values for ( i j ), is a subset of the ij Cartesian product ( i ) ( j ). Asking whether a pair of values is allowed by a constraint is called a constraint check. Any constraint network can be associated with a constraint graph in which the nodes are the variables of the network, and an edge links a pair of nodes if and only if there is a constraint on the corresponding variables. init ( i ) denotes the set of nodes sharing an edge with the node i (its initial neighbors ). We de ne the set ( i ) as the current neighborhood of i , namely, the neighbors remaining uninstantiated once a backtracking search procedure has instantiated

人工智能-人工智能05约束满足问题53页 精品

人工智能-人工智能05约束满足问题53页 精品

Example: Map-Coloring
变量 WA, NT, Q, NSW, V, SA, T 值域 Di = {red,green,blue} 约束: adjacent regions must have different colors
e.g., WA ≠ NT, or (if the language allows this), or (WA,NT) ∈ {(red,green),(red,blue),(green,red), (green,blue), … }
第五章 约束满足问题
Review: Last Chapter
• Best-first search Heuristic functions estimate costs of shortest paths Good heuristics can dramatically reduce search cost Greedy best-first search expands lowest h — incomplete and not always optimal A* search expands lowest g+ h — complete and optimal — also optimally efficient (up to tie-breaks, for forward search) Admissible heuristics can be derived from exact solution of relaxed problems
CSP的种类
离散变量 • finite domains 有限值域:
n 个变量, 值域大小d → O(dn) 完全赋值 e.g., Boolean CSPs/布尔CSP问题(NP-complete) • infinite domains 无限值域 (integers, strings, etc.) e.g., job scheduling, variables are start/end days for each job 不能通过枚举来描述值域,只能用约束语言 , e.g., 线性约束可解, 非线性约束不可解

高校排课问题的约束满足优化模型与算法

高校排课问题的约束满足优化模型与算法

SCIENCE &TECHNOLOGY VISION 科技视界0引言随着高校规模的不断扩大、专业的不断扩充、以及教学设施的不断完善,教务管理工作的难度逐年加大,作为教务管理关键工作之一的课程编排问题也成为了当前教务人员所面临的复杂问题。

杨林根[1]提出了基于免疫遗传算法的排课问题解决方案,但未考虑课程对于教学楼的特殊要求;王超[2]针对机房排课问题,设计了改进的离散粒子群算法进行求解;针对中职院校的排课需求,张燕芬[3]提出了一个基于银行家算法和贪心算法的排课算法;针对高职院校的排课特点,吴小丽[4]对排课系统的基本功能模块和主要和新算法实现进行了研究与分析。

约束满足是一种组合优化问题的建模与求解技术,它能以更加接近现实世界的方式描述调度问题及其约束,在约束求解中,能够充分利用问题的结构信息、约束关系,采用约束传播、回溯、搜索等技术对求解空间快速缩减,提高问题的求解效率。

本文考虑了高等院校的排课问题对于不同教学楼的特殊需求,将其映射为一类约束满足问题,进而建立以最优化教室负荷均衡性为目标的约束满足优化模型。

针对模型中硬性约束和柔性约束并存的特殊情况,设计了问题的约束满足求解算法。

1排课优化模型1.1问题描述高校排课问题是在课程及任课教师已定的情况下,为每一门课程选定适当的教室和时间,以确保教学计划的正常进行。

在排课过程中,应当综合考虑教室、教师、时间等资源的限制,遵循以下原则:1)同一个班级的不同课程不允许安排在同一时间。

2)同一名教师的不同课程不允许安排在同一时间。

3)同一个教室在同一时间只允许至多安排一门课程。

4)教室能容纳的学生数不小于在该教室上课的人数。

5)同一门课程不允许在同一天内连续上两节或两节以上。

此外,由于高校是具有多学院、多专业的高等院校,每个学院往往是有其专门的学院楼,因此,在排课过程中应尽量满足学院、教师、教室、班级等特殊需求,例如:课程指派应尽可能的分散在不同的教室;专业课应主要安排在该学院所在的教学楼内的教室进行,公共课则必须安排在公共教学楼;尽量满足个别教师教课时间的特殊要求。

AI约束满足问题CSP

AI约束满足问题CSP

Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}
约束的清晰表示 约束传播算法
约束满足问题 (CSP) Constraint Satisfaction Problem (CSP)
变量的集合 variables {X1, X2, …, Xn} 每一个变量Xi所有可能的取值,构成该变量 的值域Di;通常Di是有限的 约束的集合 constraints {C1, C2, …, Cp} 每个约束描述了一个变量子集与特定的某些 值合法的结合对应关系 目标: 每一个变量都得到了一个赋值,且所有 的约束得到满足
地图着色问题
NT
WA SA Q NSW T
V
7 个变量 {WA,NT,SA,Q,NSW,V,T} 每个变量的值域是一样的: {red, green, blue} 两个相邻的变量不能取相同的值:
WANT, WASA, NTSA, NTQ, SAQ, SANSW, SAV,QNSW, NSWV
owns the Zebra? drinks Water?
Street Puzzle
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}

A Dichotomy Theorem for Constraints on a Three-Element Set

A Dichotomy Theorem for Constraints on a Three-Element Set

A Dichotomy Theorem for Constraints on a Three-Element SetAndrei A.BulatovComputing Laboratory,University of Oxford,Oxford,UKE-mail:Andrei.Bulatov@AbstractThe Constraint Satisfaction Problem(CSP)provides a common framework for many combinatorial problems.The general CSP is known to be NP-complete;however,certain restrictions on the possible form of constraints may affect the complexity,and lead to tractable problem classes.There is,therefore,a fundamental research direction,aiming to separate those subclasses of the CSP which are tractable, from those which remain NP-complete.In1978Schaefer gave an exhaustive solution of this problem for the CSP on a2-element domain.In this paper we generalise this result to a classification of the complex-ity of CSPs on a3-element domain.The main result states that every subclass of the CSP defined by a set of allowed constraints is either tractable or NP-complete,and the cri-terion separating them is that conjectured in[6,8].We also exhibit a polynomial time algorithm which,for a given set of allowed constraints,determines whether if this set gives rise to a tractable problem class.To obtain the main result and the algorithm we extensively use the algebraic technique for the CSP developed in[17]and[6,8].1.IntroductionIn the Constraint Satisfaction Problem(CSP)[24]we aim tofind an assignment to a set of variables subject to specified constraints.Many combinatorial problems ap-pearing in computer science and artificial intelligence can be expressed as particular subclasses of the CSP.The stan-dard examples include the propositional satisfiability prob-lem,in which the variables must be assigned Boolean val-ues,graph colorability,scheduling problems,linear systems and many others.One advantage of considering a com-mon framework for all of these diverse problems is that it makes it possible to obtain generic structural results con-cerning the computational complexity of constraint satis-faction problems that can be applied in many different areas such as database theory[21,33],temporal and spatial rea-soning[30],machine vision[24],belief maintenance[11],technical design[26],natural language comprehension[1], programming language analysis[25],etc.The general CSP is NP-complete;however,certain re-strictions on the allowed form of the constraints involved may ensure tractability.Therefore,one of the main ap-proaches in the study of the CSP is identifying tractable subclasses of the general CSP obtained in this way[14,15, 9,17,29].Developments in this direction provide an ef-ficient algorithm solving a particular problem,if the prob-lem falls in one of the known tractable subclasses,or as-sist in speeding up of general superpolynomial algorithms [12,13,22].To formalize the idea of restricting the allowed constraints,we make use of the notion of a constraint lan-guage[16],which is simply a set of possible relations that can be used to specify constraints in a problem.We say that a constraint language is tractable[intractable]if the corresponding problem class is tractable[intractable.The ultimate goal of this research direction is tofind the pre-cise border between tractable and intractable constraint lan-guages.This goal was achieved by Schaefer[29]in the important case of Boolean constraints;he has characterised tractable constraint languages on a2-element set,and proved that the rest are NP-complete.This Schaefer’s result is known as Shaefer’s Dichotomy Theorem.Dichotomy theorems are of particular interests in study of the CSP,because,on the one hand,they determine the precise complexity of constraint languages,and on the other hand,the a priori existence of a dichotomy result cannot be taken for granted.For a short survey of dichotomy results the reader is referred to[9].The analogous problem,which is referred to as the clas-sification problem,for the CSP in which the variables can be assigned more than2values,remains open since1978, in spite of intensive efforts.For instance,Feder and Vardi, in[14],used database technique and group theory to iden-tify some large tractable families of constraints;Jeavons and coauthors have characterised many tractable and NP-complete constraint languages using invariance properties of constraints[17,18,19];in[8],a possible form of a di-chotomy result for the CSP onfinite domains was conjec-tured;in[7],a dichotomy result was proved for a certaintype of constraint languages on a3-element domain.In this paper we generalise the results of[29]and[7],and provethe dichotomy conjecture from[8]for the constraint sat-isfaction problem on a3-element domain.In particular, we completely characterise tractable constraint languagesin this case,and prove that the rest are NP-complete.The main result will be precisely stated at the end of Section2.The classification problem for constraint languages on aset containing more than2elements,even on a3-element set,turns out to be much harder than that for the2-elementcase.Besides the obvious reason that Boolean CSPs closely relate to various problems from propositional logic,and therefore,are much better investigated,there is another deepreason.As is showed in[19,20,17],when studying the complexity of constraint languages we may restrict our-selves with a certain class of languages,so called relationalclones.There are only countably many relational clones on a2-element set,and all of them are known[28].However,the class of relational clones on a3-element set already con-tains continuum many elements,and any its explicit charac-terization is believed to be unreachable.Another problem tackled here is referred to,in[9],as themeta-problem:given a constraint language determine if this language gives rise to a tractable problem class.Making useof the dichotomy theorem obtained we exhibit an effective algorithm solving the meta-problem for the CSP on a3-element domain.The technique used in this paper relies upon the idea,that was developed in[8,6,17](and also mentioned in[14]as a possible direction for future research),that algebraic in-variance properties of constraints can be used for studying the complexity of the corresponding constraint satisfaction problems.The main advantage of this technique is that itallows us to employ structural results from universal alge-bra.The algebraic approach has proved to be very fruitfulin identifying tractable classes of the CSP[2,4,18].We strongly believe that the synthesis between complexity the-ory and universal algebra which we describe here is likelyto lead to new results in bothfields.2.Algebraic structure of CSP classes2.1.The Constraint Satisfaction ProblemThe set of all-tuples with components from a set isdenoted.The th component of a tuple will be denoted .Any subset of is called an-ary relation on;and a constraint language on is an arbitrary set offinitaryrelations on.Definition1The constraint satisfaction problem()over a constraint language,denoted,is defined to be the decision problem with instance,where Instance:is a set of variables;is a set of values(some-times called a domain);and is a set of constraints,,in which the constraint is a pair with is a tuple of variables of length, called the constraint scope,and an-ary re-lation on,called the constraint relation. Question:is whether there exists a solution to, that is,a function from to,such that,for each constraint in,the image of the constraint scope is a member of the constraint relation.We shall be concerned with distinguishing between those constraint languages which give rise to tractable problems (i.e.,problems for which there exists a polynomial-time so-lution algorithm),and those which do not.Definition2A constraint language,is said to be tractable,if is tractable for eachfinite subset .It is said to be NP-complete,if is NP-complete for somefinite subset.By a Boolean constraint language we mean a constraint language on a2-element set,usually.In[29],Schae-fer has classified Boolean constraint languages with re-spect to complexity.This result is known as Schaefer’s Di-chotomy theorem.Theorem1(Schaefer,[29])A constraint language,,on is tractable if one of the following conditions holds:(1)every in contains;(2)every in contains;(3)every in is definable by a CNF formula in whicheach clause has at most one negated variable;(4)every in is definable by a CNF formula in whicheach clause has at most one unnegated variable; (5)every in is definable by a CNF formula in whicheach clause has at most two literals;(6)every in is the solution space of a linear systemover.Otherwise is NP-complete.More examples of both tractable and NP-complete con-straint languages will appear later in this paper and can also be found in[8,10,14,19].It follows from Theorem1 that every Boolean constraint language is either tractable or NP-complete;and so,there is no language of intermedi-ate complexity.Some dichotomy results have been obtained for other variations of Boolean CSP[9].The classification problem for larger domains is still open and seems to be very interesting and hard[14].Problem1(classification problem)Characterise all trac-table constraint languages onfinite domains.2.2.Algebraic structure of problem classesSchaefer’s technique heavily uses the natural representa-tion of Boolean relations by propositional formulas.Such a representation does not exist for larger domains.Instead, we shall use algebraic properties of relations.In our alge-braic definitions we mainly follow[23].Definition3An algebra is an ordered pairsuch that is a nonempty set and is a family offinitary operations on.The set is called the universe of,the operations from are called basic.An algebra with afinite universe is referred to as afinite algebra.Every constraint language on a set can be assigned an algebra with the universe.Definition4An-ary operation preserves an-ary re-lation(or is a polymorphism of,or is invariant un-der)if,for any, the tuple belongsto as well.The set of all polymorphisms of a constraint language is denoted;and the set of all relations invariant under all operations from a set is denoted.Given a constraint language,,on,the algebra is called the algebra associated with,and is denoted.Conversely,for anyfinite algebra,there is a constraint language associated with,the language, and the associated problem class. Notice that is the largest constraint language such that,see,e.g.[27,31].A connection between the complexity of a constraint language and the associated algebra is provided by the following theorem.Theorem2([17])A constraint language on afinite set is tractable[NP-complete]if and only if is tractable[NP-complete].Informally speaking,Theorem2says that the complexity of is determined by the algebra.We,therefore,make the following definition:for a constraint language,the alge-bra is said to be tractable[NP-complete]if is tractable [NP-complete].In[18,19],Jeavons and coauthors have identified cer-tain types of algebras which give rise to tractable problem classes.Definition5Let be afinite set.An operation on is calleda projection if there is such thatfor any;essentially unary if,for some unary operation,and any;a constant operation if there is such that,for any;idempotent if for any.a semilattice operation1,if it is binary idempotent andfor any satisfies the following two condi-tions:(a)(Associativity),(b)(Commutativity);a majority operation if it is ternary,and,for any;affine if where are the operations of an Abelian group.For afinite algebra,an operation from is said to be a term operation2of.If is a constraint language, the term operations of are the polymorphisms of. Proposition1([18,19])If afinite algebra has a term operation which is constant,semilattice,affine,or major-ity,then is tractable.The2-element algebras associated with Schaefer’s six types of constraint languages have the constant term operation or in cases(1),(2);the semilattice term operation or in cases(3),(4);the majority term operationin case(5);and the affine term operation in case(6).An algebra is said to be a-set if every term operation is essentially unary and the corresponding unary operation is a permutation.Proposition2([18,19])Afinite-set is NP-complete. By combining those two results,and the classical result of E.Post[28],the algebraic version of Schaefer’s theorem can be derived[8].Theorem3(Schaefer)A constraint language on a2-element set is tractable if is not a-set.Otherwise is NP-complete.2.3.Algebraic constructions and the complexity ofconstraint languagesCertain transformations of constraint languages preserve the complexity,and may lead to languages with certain de-sirable properties.Let be a constraint language on,anda unary polymorphism of such that. By we denote the set where;and by the set.If is a unary operation whose range is minimal among ranges of unary operations from with the property, then the constraint language will be denoted. Proposition3([8])Let be a constraint language on, and a unary operation on with a minimal range and such that.Then is tractable [NP-complete]if and only if is tractable[NP-complete]. If and satisfy the conditions of Proposition3then the algebra is idempotent,that is,all its basic operations are idempotent.The complexity of the constraint language does not depend on the choice of,and we shall denote every such language by.Due to Theorem2and Proposition3the study of the complexity of constraint languages is completely reduced to the study of properties of idempotent algebras.Definition6Let be an algebra,and a sub-set of such that,for any(-ary),and for any,we have.Then the al-gebra consists of restrictions of operations from onto,is called a subalgebra of.The universe of a subalgebra of is called a subuniverse of.An equivalence relation is said to be a con-gruence of.The-class containing is denoted, the set is said to be the factor-set, and the algebra,where,is said to be thefactor-algebra.Proposition4([8])Let be a tractable constraint lan-guage on,a subuniverse of,and an equiva-lence relation invariant under.Then(1)the subalgebra,for a natural number,we will denote the set.Let be an-ary relation,and;Definition7The algebrasatisfies the partial zero property if there exist a set of its subuniverses,,and for each,such that(a);(b)for any relation,and any,there is withifotherwisesatisfies the splitting property if any(-ary)relationcan be represented in the form, contains the tuple withifif andif andsatisfies the-semisplitting property if,for any ir-reducible(-ary)relation,we have(i)procedure until the instance stays unchanged:solve all re-stricted problems involving variables,and then remove from each constraint all tuples such thatis a part of no partial solution for a certain-element set of variables.This procedure is called‘establishing-minimality’,and is said to be the-minimal instance associated with.Definition9A class of constraint satisfaction problems is said to be of width3if any problem instance from has a solution if and only if the-minimal problem associ-ated with contains no empty constraint.Every class offinite width is tractable,because,assuming fixed,establishing-minimality takes polynomial time. 4.2.Multi-sorted constraint satisfaction problemsIn[5],an algebraic approach to a generalised version of the constraint satisfaction problem was developed.In this generalised version every variable is allowed to have its own domain.In this paper we need the notion of multi-sorted constraint satisfaction problem,and some results from[5] as an auxiliary tool.Definition10For any collection of sets, and any list of indices,a subset of,together with the list, will be called an(-ary)relation over with signature.For any such relation,the th compo-nent of the signature of will be denoted.Definition11The multi-sorted constraint satisfaction problem is the combinatorial decision problem with Instance:a quadruple where is a set of vari-ables;is a collection of sets of values[domains];is a mapping from to, called the domain function;is a set of constraints.Each constraint is a pair,whereis a tuple of variables of length, called the constraint scope;is an-ary relation over with signature,called the constraint relation.Question:does there exist a solution,i.e.a function, from to,such that,for each variable,,and for each constraint, with,the tuplebelongs to?It is possible to introduce the algebraic structure of the multi-sorted CSP in a very similar way to the usual one.Corollary1If a3-element idempotent algebra satisfies (N O-G-S ET)then any2-valued problem instance from can be solved in polynomial time.Most of the‘good’properties of relations allow us,first,to reduce an arbitrary problem instance to a2-valued problem instance,and,second,to solve the obtained instance as amulti-sorted problem instance by making use of the algo-rithms from[5].4.3.Why‘good’properties are good4.3.1.Relations invariant with respect to a special oper-ation.In condition(8)of Theorem5,the tractability offollows from Proposition1.In(9),is of width3,as is proved in[4].The result of[2]states that anyfinite alge-bra with a Mal’tsev operation is tractable,and the solutionalgorithm is very similar to algorithms from linear algebra.4.3.2.The partial zero property.In this case any prob-lem instance can be reduced to a2-valued one.Indeed,if satisfies the partial zero property,and a1-minimal probleminstance has a solution,then also has the solution such that if, and otherwise.Thus,to solve we assignthe value to each variable with. Since,the obtained problem instance is2-valued.4.3.3.The replacement property.In this case any prob-lem instance can also be reduced to a2-valued one.If satisfies the-replacement property,and a1-minimal problem instance has a solu-tion,then the mapping such thatif,,and otherwise, is a solution to.We therefore,may reduce to a2-valued problem instance where for eachthere is such that if and only if and whenever.4.3.4.The extendibility property.We prove that in this case is of width3.Suppose that satisfies the -extendibility property,and take a3-minimal problem in-stance.An easy proof of the following lemma is left to the reader.Lemma1Let.There is such that,for any.Finally,the-extendibility property of implies that the mapping whereifif oris a solution to.4.3.5.Rectangularity and semirectangularity.Suppose that is-rectangular or-semirectangular,and.We show that any problem instance in this case can be reduced to a2-valued one.Take a problem instance.Without loss of generality we may assume that is3-minimal.Let denote the set of all variables with.Let be the equivalence relation on generated by. Notice that,since is3-minimal,for any,any such that,and any,ei-ther,or.Repeat the follow-ing procedure until the obtained problem instance coincides with the previous one.For each class of,solve the problemwhere,for each,we make the constraint.If,for a class of,the problem instancehas no solution then,for each constraint, remove from all the tuples such that for some.Replace the obtained problem instance with the asso-ciated3-minimal problem instance.Remove from those variables for which no longer equals or.Calculate the relation for the obtained problem instance and the set.Obviously,the obtained problem instance has a solution if and only if the original problem instance has.Supposefirst that is-rectangular.Then,if has no empty constraint,then there is a solution to such that whenever.Indeed,letbe the classes of,and a solution to,It is not hard to see that if has a solution,then has a solution(see also[4]).Let be a solution to,andsolutions to.The mapping whereifif,,andif,,andis a solution to.Indeed,take a constraint. Since for eachis the majority opera-tion,and satisfies the-semisplitting property.A prob-lem instance is said to be irreducible if every constraint relation is irreducible.Every3-minimal problem instancecan be reduced to an equivalent irreducible problem instance in polynomial time.Indeed,denote by the binary relation on such that if and only if is the graph of a bijec-tive mapping.Since is3-minimal,,for any,where denotes the composition of binary relations;hence,is an equivalence relation.Choose a representative from each class of,and let be the set of the representatives.Then, for no pair of variables,is the graph of a bijective mapping,and for any,there issuch that is the graph of a bijective mapping.We transform in three steps.For each constraint and any,replacewith where,andis the representative of the-class containing.For each constraint and each,re-place with.Replace every constraint with.Now,let be a3-minimal ir-reducible problem instance,and consider the instancewhere,for each,there iswith for all such that .The problem instance is2-valued,there-fore,we just have to show that and are equivalent.Clearly,if has a solution then has a solution.Con-versely,let have a solution,and set,and.By condition(i)of the definition of the semisplitting property,has a solution if and only if both and have.Since,the instance has a solution.By condition(ii),for any,where denotes the set of partial solutions to for.Moreover,since is3-minimal,for any every such partial solution can be extended to a solution from.(The last property is called strong2-consistency[18].)Recall that any relation such that is invariant with respect to a majority operation,in particular,all the constraint rela-tions of satisfy this condition.By Theorem3.5of[18], if for any then strong2-consistency ensures existence of a solution to.5.Recognising tractable casesFrom a practical perspective,we need a method that al-lows us to recognise if a given constraint language is tractable.The following problem is,therefore,very tempt-ing.T RACTABLE-L ANGUAGE.Is a givenfinite constraint lan-guage on afinite set tractable?Schaefer’s Dichotomy Theorem[29]does not solve this problem satisfactorily.Indeed,it can be easily verified if a relation satisfies conditions(1)or(2)of Theorem1,how-ever,the way of recognising if one of conditions(3)–(6) holds is not obvious(see also[21]).Theorem3,the alge-braic version of Schaefer’s result,fills this gap:to check the tractability of a Boolean constraint language one just has to check whether all relations from the language are invari-ant under one of the6Boolean operations corresponding to conditions(1)–(6).In the general case,such a method can hopefully be de-rived from a description of tractable algebras.For example, in[6],a polynomial time algorithm has been exhibited that checks if afinite algebra,whose basic operations are given explicitely by their operation tables,satisfies(N O-G-S ET). Therefore,if Conjecture1holds then the tractability of an algebra can be tested in polynomial time.In particular,this algorithm is valid in the case of3-element algebras.However,this algorithm does not solve T RACTABLE-L ANGUAGE even under the assumption of Conjecture1, because in this problem we are given a constraint language, not an algebra.Actually,we need to solve the problemN O-G-S ET-L ANGUAGE.Given afinite constraint language on afinite set,does the algebra satisfy(N O-G-S ET)?By the results of[6],this problem is NP-complete.How-ever,its restricted version remains tractable.N O-G-SET-L ANGUAGE().Given afinite constraint lan-guage on afinite set,,does the algebra satisfy(N O-G-S ET)?This means that the tractability of a constraint language on a3-element set can be tested in polynomial time.Theorem7There is a polynomial time algorithm that given a constraint language on a3-element set determines if is tractable.An example of such an algorithm is provided by the gen-eral algorithm from[6].That algorithm employs some deep algebraic results and sophisticated constructions.In the par-ticular case of a3-element domain,we may avoid using hard algebra,and apply a simpler and easier algorithm.To this end,notice that if a3-element idempotent algebra has a2-element subuniverse or a nontrivial congruence, and there is a term operation which is not a projection on the subalgebra or the factor-algebra,then witnesses that the algebra itself is also not a-set.We,therefore,have two cases to consider.C ASE1.has no2-element subuniverse,and no proper congruence.Such an algebra is said to be strictly simple.There is a com-plete description offinite strictly simple algebras[32].In particular,if a strictly simple algebra satisfies(N O-G-S ET) then one of the following operations is its term operation: a majority operation,the affine operation of an Abelian group,or the operationifotherwisefor some element.C ASE2.has either a2-element subalgebra,or a proper congruence.In this case,satisfies(N O-G-SET)if and only if every2-element subalgebra and every proper factor-algebra(which is also2-element)is not a-set.In its turn,the latter con-dition holds if and only if,for any2-element subuniverse of,and any congruence,there is a polymorphism of such that()is one of the Boolean operations,,,;–if not then output“NO”.Output“Yes”.This algorithm is polynomial time,because the hardest step,finding the set,requires inspecting of all ternary operations on a3-element set;and,since their number does not depend on,takes cubic time.Recognising which of the10properties a tractable al-gebra satisfies also can be completed in polynomial time. However,to establish this requires a more detailed study of the set of ternary polymorphisms,see[3].6ConclusionIn fact,Theorem5implies a stronger result than that claimed in Theorem4.The difference appears when consid-ering infinite constraint languages satisfying the conditions of Conjecture1.Theorem4claims that,for anyfinite sub-set of such a language,there is its own polynomial time algorithm solving,and for different sub-sets the corresponding algorithms might be quite different.Theorem5yields a uniform polynomial time algorithm that solves any problem from the class associated with the con-straint language.Moreover,from the proof of Theorem5a general algorithm can be derived,which solves any problem instance on a3-element set provided that, for some tractable.Note that Theorem4is proved by a‘brute force’method, that is,by analysing a large number of operations which provide the condition(N O-G-S ET).We believe that devel-opment of algebraic tools and more subtle usage of results from universal algebra will make it possible to obtain di-chotomy results for larger domains,and eventually,for an arbitraryfinite domain.References[1]J.Allen.Natural Language Understanding.Benjamin Cum-mihgs,1994.[2] A.Bulatov.Mal’tsev constraints are tractable.TechnicalReport PRG-RR-02-05,Computing Laboratory,University of Oxford,Oxford,UK,2002.[3] A.Bulatov.Tractable constraints on a three-element set.Technical Report PRG-RR-02-06,Computing Laboratory, University of Oxford,Oxford,UK,2002.[4] A.Bulatov and P.Jeavons.Tractable constraints closed un-der a binary operation.Technical Report PRG-TR-12-00, Computing Laboratory,University of Oxford,Oxford,UK, 2000.[5] A.Bulatov and P.Jeavons.Algebraic approach to multi-sorted constraints.Technical Report PRG-RR-01-18,Com-puting Laboratory,University of Oxford,Oxford,UK,2001.[6] A.Bulatov and P.Jeavons.Algebraic structures in combina-torial problems.Technical Report MATH-AL-4-2001,Tech-nische universit¨a t Dresden,Dresden,Germany,2001. [7] A.Bulatov,P.Jeavons,and A.Krokhin.The complex-ity of maximal constraint languages.In Proceedings of the33rd Annual ACM Simposium on Theory of Comput-ing,pages667–674,Hersonissos,Crete,Greece,July2001.ACM Press.[8] A.Bulatov,A.Krokhin,and P.Jeavons.Constraint sat-isfaction problems andfinite algebras.In Proceedings of 27th International Colloquium on Automata,Languages and Programming—ICALP’00,volume1853of Lecture Notes in Computer Science,pages272–282.Springer-Verlag,2000.[9]N.Creignou,S.Khanna,and plexity Classi-fications of Boolean Constraint Satisfaction Problems,vol-ume7of SIAM Monographs on Discrete Mathematics and Applications.SIAM,2001.[10]putational Complexity of Problems overGeneralised Formulas.PhD thesis,Department LSI of the Universitat Politecnica de Catalunya(UPC),Barcelona., March,2000.[11]R.Dechter and A.Dechter.Structure-driven algorithmsfor truth maintenance.Artificial Intelligence,82(1-2):1–20, 1996.[12]R.Dechter and I.Meiri.Experimental evaluation of prepro-cessing algorithms for constraint satisfaction problems.Ar-tificial Intelligence,68:211–241,1994.[13]R.Dechter and work-based heuristics for con-straint satisfaction problems.Artificial Intelligence,34(1):1–38,1988.[14]T.Feder and M.Vardi.The computational structure ofmonotone monadic SNP and constraint satisfaction:A study through datalog and group theory.SIAM Journal of Comput-ing,28:57–104,1998.[15]G.Gottlob,L.Leone,and F.Scarcello.A comparison ofstructural CSP decomposition methods.Artificial Intelli-gence,124(2):243–282,2000.[16]P.Jeavons.Constructing constraints.In Proceedings4th In-ternational Conference on Constraint Programming—CP’98 (Pisa,October1998),volume1520of Lecture Notes in Com-puter Science,pages2–16.Springer-Verlag,1998.[17]P.Jeavons.On the algebraic structure of combinatorial prob-lems.Theoretical Computer Science,200:185–204,1998.[18]P.Jeavons,D.Cohen,and M.Cooper.Constraints,consis-tency and closure.Artificial Intelligence,101(1-2):251–265, 1998.[19]P.Jeavons,D.Cohen,and M.Gyssens.Closure properties ofconstraints.Journal of the ACM,44:527–548,1997. [20]P.Jeavons,D.Cohen,and J.Pearson.Constraints and uni-versal algebra.Annals of Mathematics and Artificial Intelli-gence,24:51–67,1998.[21]P.Kolaitis and M.Vardi.Conjunctive-query containment andconstraint put.Syst.Sci.,61:302–332, 2000.[22]V.Kumar.Algorithms for constraint satisfaction problems:A survey.AI Magazine,13(1):32–44,1992.[23]R.McKenzie,G.McNulty,and W.Taylor.Algebras,Latticesand Varieties,volume I.Wadsworth and Brooks,California, 1987.[24]works of constraints:Fundamental prop-erties and applications to picture rmation Sciences,7:95–132,1974.[25] B.Nadel.Constraint satisfaction in Prolog:Complexity andtheory-based rmation Sciences,83(3-4):113–131,1995.[26] B.Nadel and J.Lin.Automobile transmission design asa constraint satisfaction problem:Modeling the kinematiklevel.Artificial Intelligence for Engineering Design,Anaysis and Manufacturing(AI EDAM),5(3):137–171,1991. [27]R.P¨o schel and L.Kaluˇz nin.Funktionen-und Relationenal-gebren.DVW,Berlin,1979.[28] E.Post.The two-valued iterative systems of mathematicallogic,volume5of Annals Mathematical Studies.Princeton University Press,1941.[29]T.Schaefer.The complexity of satisfiability problems.InProceedings10th ACM Symposium on Theory of Computing (STOC’78),pages216–226,1978.[30] E.Schwalb and L.Vila.Temporal constraints:a survey.Con-straints,3(2-3):129–149,1998.[31] A.Szendrei.Clones in Universal Algebra,volume99ofSeminaires de Mathematiques Superieures.Universit´e de M´o ntreal,1986.[32] A.Szendrei.Simple surjective algebras having no propersubalgebras.Journal of the Australian Mathematical Society (Series A),48:434–454,1990.[33]M.Vardi.Constraint satisfaction and database theory:a tu-torial.In Proceedings of19th ACM Symposium on Priciples of Database Systems(PODS’00),2000.。

AI约束满足问题CSP

AI约束满足问题CSP

Constraint Propagation
3 4 4 3 3 3 4 5
4
3 3 5
重复前述过程
Constraint Propagation
3 3 4 3 4 3
3
2 3 4
Constraint Propagation
3 3 4 3 1
2
2 1 3
Constraint Propagation
The The The The The The The The The The The The The The
Englishman lives in the Red house i,j[1,5], Spaniard has a Dog Japanese is a Painter ... Italian drinks Tea Norwegian lives in the first house on the left owner of the Green house drinks Coffee Green house is on the right of the White house Sculptor breeds Snails Diplomat lives in the Yellow house owner of the middle house drinks Milk Norwegian lives next door to the Blue house Violinist drinks Fruit juice Fox is in the house next to the Doctor’s Horse is next to the Diplomat’s
1 2 3 4 5
Ni = {English, Spaniard, Japanese, Italian, Norwegian} Ci = {Red, Green, White, Yellow, Blue} Di = {Tea, Coffee, Milk, Fruit-juice, Water} Ji = {Painter, Sculptor, Diplomat, Violinist, Doctor} Ai = {Dog, Snails, Fox, Horse, Zebra}

若干集合覆盖问题的方法研究

若干集合覆盖问题的方法研究

摘要摘要若干集合覆盖问题的方法研究集合覆盖是一个重要的组合优化问题,被广泛应用于人工智能不同的领域。

近年来,其关键性子问题研究主要集中在经典最小集合覆盖问题、最小加权集合覆盖问题、极小集合覆盖问题和最大集合K覆盖问题,它们具有非常重要的研究意义和广泛的应用领域。

本文将围绕上述四个集合覆盖子问题展开,旨在为不同应用需求子问题设计对应的高效求解方法。

针对集合覆盖子问题,求解方法主要分成两大类:精确求解方法和启发式求解方法。

使用精确求解方法解决时,可以保证得到的候选解是最优解。

但随着求解问题规模不断扩大,精确求解方法的求解时间呈指数上升,此时无法保证在可接受的时间内返回一个候选解。

启发式方法在合理的求解时间内能够获得一个尽可能好的候选解,但是不能保证这个候选解是最优解。

因此,启发式方法适用于大规模问题以及对解的质量要求不过于苛刻的情况。

在实际应用中,经典最小集合覆盖问题,最小加权集合覆盖问题和最大集合K覆盖问题所需要处理的问题规模往往较大,此时使用精确求解方法很难进行有效求解。

针对这三个问题,本文针对其分别提出启发式求解方法:针对经典最小集合覆盖问题,本文提出一种迭代局部搜索求解方法,该方法使用三个策略:超图边配置检测策略、权值变化策略和超图边选择策略;针对最小加权集合覆盖问题,本文提出一种新的局部搜索框架并辅以带有问题化简的预处理、低复杂度的初始化策略和多值随机选择策略;针对最大集合K覆盖问题,本文提出一种重启局部搜索方法,该方法使用了随机重启初始化和快速邻居搜索两个策略。

由于极小集合覆盖问题对解的质量要求较高,而启发式求解方法得到的候选解精度较低。

针对此问题,本文提出一种精确极小集合覆盖求解方法,该方法将极小集合覆盖问题转化为约束可满足问题,然后再进行求解。

具体工作如下:1)对于经典最小集合覆盖问题,提出一种基于迭代局部搜索的uSLC方法。

该方法使用超图形式表示经典最小集合覆盖问题,辅以三个策略对问题求解效率进行提高:超图边配置检测策略、权值变化策略和超图边选择策略。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1. Introduction: Constraint Satisfaction Problems Engineers offer encounter problems with many degrees of freedom (‘variables’) but also many constraints. The problem is to find a value of the variables which satisfies all constraints, or the most probable configuration of variable given the constraints and some a priori measure. Obvious applications are scheduling (classes, airplanes...), or job assignment. But similar problems occur in various branches of scientific activity, and are crucial in several domains. To be short we shall focus here on four of them. The satisfiability problem is at the core of the theory of computational complexity in computer science. Error correcting codes are one of the main topic of information theory. Learning
Thierry Mora
Lewis-Sigler Institute for Integrative Genomics, Princeton University, Princeton, Nct A new field of research is rapidly expanding at the crossroad between statistical physics, information theory and combinatorial optimization. In particular, the use of cutting edge statistical physics concepts and methods allow one to solve very large constraint satisfaction problems like random satisfiability, coloring, or error correction. Several aspects of these developments should be relevant for the understanding of functional complexity in neural networks. On the one hand the message passing procedures which are used in these new algorithms are based on local exchange of information, and succeed in solving some of the hardest computational problems. On the other hand some crucial inference problems in neurobiology, like those generated in multi-electrode recordings, naturally translate into hard constraint satisfaction problems. This paper gives a non-technical introduction to this field, emphasizing the main ideas at work in message passing strategies and their possible relevance to neural networks modelling. It also introduces a new message passing algorithm for inferring interactions between variables from correlation data, which could be useful in the analysis of multi-electrode recording data.
arXiv:0803.3061v1 [q-bio.NC] 20 Mar 2008
Constraint satisfaction problems and neural networks: a statistical physics perspective
Marc M´ ezard
LPTMS, UMR 8626 CNRS et Univ. Paris-Sud, 91405 Orsay CEDEX, France
Preprint submitted to Elsevier 20 March 2008
from examples is a basic process in cognitive neuroscience. Reconstruction of neuron interactions from multi-electrode recording is a problem which is becoming more and more important. All these problems can be formulated in a common language (M´ ezard & Montanari, 2008), and have a strong relationship to fundamental issues in statistical physics like the existence of phase transition, and the possibility of glassy phases. They can also be cast into a somewhat generic formalism, based a graphical representation of the topology of constraints (Kschischang et al., 2001), which allows to apply a general ‘message passing’ strategy to all of them. Some of these message passing algorithms have actually shown strikingly good performance, solving some problems in satisfiability or perceptron learning that are unreachable by any other algorithms. It is interesting in itself to understand how fundamental issues in computational complexity and information processing can be formulated in the same language as relevant problems in neuroscience, the main aim of this paper is to give some clues on these connexions. 2. Satisfiability The problem of satisfiability involves N Boolean variables xi ∈ {T, F }. There exist thus 2N possible configurations of these variables. The constraints take the special form of ‘clauses’, which are logical ‘OR’ functions of the variables. For instance the clause x1 ∨ x2 ∨ x ¯3 is satisfied whenever x1 = T or x2 = T or x3 = F (the bar means negation: ¯ = F and F ¯ = T ). Therefore, among the 8 possible configurations of x1 , x2 , x3 , the T only one which is forbidden by this clause is x1 = x27 = 0, x3 = 1. An instance of the satisfiability problem is given by the list of all the clauses it contains. The problem is to find a choice of the Boolean variables (called an ’assignment’) such that all constraints are satisfied. When there exists such a choice the corresponding instance is said to be ‘SAT’, otherwise it is ‘UNSAT’, and one typically seeks a configuration of variables which violates the smallest number of constraints. Satisfiability plays an essential role in the theory of computational complexity, because many other difficult problems like the traveling salesman, the colouring of graphs, scheduling, protein folding, can be mapped ‘polynomially’ to it. It was the first problem which has been shown to be ‘NP-complete’ (Cook, 1971). This means that if one could find an algorithm that solves satisfiability in a ‘polynomial’ time (growing like a power of N ), one could also solve all these other problems in polynomial time: life would be much easier, in particular the life of scientists... This is generally considered unlikely, but the corresponding mathematical problem (whether the NP class is distinct or not from the ‘P’ class of problems which are solvable in polynomial time) is an important open problem in mathematics. The result of Cook is a worst case analysis of the satisfiability problem. However it appears more and more important to study ‘typical case’ complexity of satisfiability problems by introducing some classes of instances. A much studied class is the random ‘3-SAT’ problem. Each clause contains exactly three variables chosen randomly in {x1 , .., xN }, and each variable is negated randomly with probability 1/2. This problem is particularly interesting because its difficulty can be tuned by varying one single control parameter, the ratio α = M N of constraints per variable. One expects intuitively that for small α most instances are SAT, while for large α most of them are UNSAT. 2
相关文档
最新文档