From: AAAI Technical Report WS-97-05. Compilation copyright © 1997, AAAI (www.aaai.org). All rights reserved. Technologyof Active Objects I. Shvetsov, T. Nesterenko,S. Starovit RussianResearchInstitute of Artificial Intelligence &Insti/ute of InformaticsSystems Lavrent’eva6, Novosibirsk,630090,Russia shvet@isi.iffs.nsk.su candidate for the role of a basic computationalparadigm for the development of multi-agent systems. Other approaches may be used within TAOto implement arbitrarily complex and"intelligent" constraints. Abstract In this paperweproposea multi-agenttechnology basedon a timed concurrent constraint programming.The technology allowsto use constraintsto specifyinteractive, reactive, dynamicand intelligent behaviorof agents. Practical valueof the. technologyis confirmedby its implementation in the agent-basedlanguageTAO-Kit for development of graphicsapplications.Some featuresof this language are considered in the paper. Constraint Programming and Agent-based Technology Constraint programming has been successfully applied to solve problemsin various fields, including sched~jling, CAD/CAM, natural language understanding, processing incompleteinformation, solving hard computationaland logical problems,data bases, etc. Its value is comparable to that of such fundamental paradigms of modem programming as, for instance, imperative, functional, or logical programming. In the classical statement, constraint programming is reduced to solving the constraint satisfaction problem (CSP). A. Mackworth(Mackworth1977) and E. Freuder (Mackworth & Freuder 1985) made a considerable theoretical contribution to the development of algorithms solving CSP.Acommon feature of these algoritluns is that they define an asynchronous data-driven process of constraint execution. It is the asynchronousmodelof computations,inherent in constraint programming, that is in our view most appropriate to describe behavior and interactionsof agents. Fromthe point of view of agent technology, CSPcan serve, for example,to formulatethe problemof computing the state of an agent given someconstraints on its parameters. The problemof transition of an agent from one state to another, however,surpasses this classical statement. In this case, concurrent constraint programming(CCP) proposed by V. Saraswat (Saraswat 1993) is more appropriate. Using the CCPparadigmwe can not only computesomestate of the agent, but also to changeit dependingon the circumstances. An important property of agents is the connection betweenthdir behaviorand time. In particular, the change of states of agents can be time-synchronized,i.e., any agent changesits state over exactly one elementarytime interval, This propertyof agents can be expressedthroug h the so-called timed CCP,formal semantics of which is presented in (Saraswat, Jagadeesan,& Gupta1994). From our point of view, semanticsof TCCP is mostadequatefor specifying the behavior of agents. At the sametime, it does not solve all problemsrelated to the operation of multi-agentsystems. Introduction Three levels are usually distinguished in agent-based technologies.Thefirst level is responsiblefor organization of interaction betweenagentsandother agentsor/and their environment. The second level implementsthe agents’ reactions, whenthey directly ("instinctively") react external events, without in-depth analysis of the ~rrent situation andforecast of the consequences of the decisions made. The third level supports a specification of intellectual propem.’esof agents whichare basedon such notions as goal-directed behavior, logical inference, knowledge accumulation, planning, learning, "look ahead,"etc, Different programming languagesand tools are used to implementeach of the technologicallevels. For instance, in the approachof 0¢lalec 1994)the interaction between agents and the outer environment is described in an expansion of C++ programming language, reactive behavioris definedin a rule-basedlanguage,andthe "look ahead" functions are expressedin non-monotone temporal logic proposedby E. Sandewall(Sandewall1994). Joint use of essentially different programmingparadigms creates certain difficulties both in the development of the technologyandin its application. In this paper weproposea technologyfor development of multi-agentsystemswhichis basedon the idea of using one common paradigm, that of constraint programming, to implementintelligent, reactive, and communicating features of agents. Wecall this approachthe technologyof active objects, or TAO for short (Nesterenkoet al. 1996), since it has somepoints in common with object-based pmgramming. Weemphasizethat in the developmentof TAOwe do not aim to use constraints to specify all functions of intelligent agent. In many cases other means and techniquesof artificial intelligence and programming in general can be moreadequateand effective. Our goal is only to show that constraint programmingis a good 64 the objectsthat are declaredas externalfor this object. At the beginningof computationof the state of someactive object, the states of all its externalobjectsmustbe known. Anactive objectcan be in differentstates. Eachstate is associated with a certain set of values of the agent’s internal slots..Eachstate is uniquelyassociatedwith a time (time is a built-in abstract notion of TAO).At each time the active object A switchesto a newstate computedas a functionof the form At present there is quite a number of powerful languagesand technologies implementingthe paradigmof constraint programming,for example,(Colmerauer1990; Dincbaset al. 1988; Puget 1994; Benhamou, McAllester, & Van Hentenryck 1994 ). However,we do not knowof constraint-based approacheswhichprovide an integrated support to the developmentof multi-agent systems. One could mention two systems, Kaleidoscope (FreemanBenson& Borning1992) and Oz(I-Ienz, Smolka,& Wurtz 1993), which possess an almost complete set of basic facilities neededto developmulti-agenttechnologiesbut are intendedto solvedifferent types of problems. From the implementation standpoint TAO is constructedas a specializedextensionof the technologyof subdefinite models(or SD-models,for short) proposed A.S.Narin~ani(Narin~ani 1983). At present SD-models are one of the most well-developed technologies of constraint programming (Shvetsov, Semenov, Telerman, 1995, 1997; Narin’yani, Borde, & Ivanov 1997). SD-technology supports both classical and concurrent constraint programming paradigms. It allows one to solve CSPfor finite and infinite domainsand for mixed cases whenthe problem combines various data types (sets, Boolean,integer and real numbers,intervals, etc.). F:(At_t, E)-, whereE are the states of other active objects visible from A. Notethat these states can refer both to the time t - 1 and to t. In the secondcase the active object can react to some events at the momentwhen they occur. This capability is necessary, for instance, to ensureadequate intera~on with sensors, whichare represented in TAOas a special kittd of active objects obtaininginformationfrom the outside world (examples: mouse, keyboard, measurement device, etc.). Thevalues of a sensorat time can be immediatelyused whencalculating the current states of relatedactiveobjects. Notethat at eachelementarystep everyactive object is executed exactly once; the computednewstate remains unchangeduntil the end of this step. Fromthe point of view of abstract time of TAO,all active objects change their states instantaneouslyandsimultaneously.In fact, however, this occurs in a certain sequence, since some objects can dependon the current states of other objects, andso will be executedafter those. Thus,the .set of active objects is a directed graph,in whichnodes are active objects and arcs (arrows) are external relations betweenthem.Thearrowscan be of two types. The first type corresponds to the dependence betweenthe current states of objects, and the second expresses their dependenceon the previous state. An exampleof suchgraphis shownin Fig. 1. Technology of Active Objects Structure of Active Objects and Interaction Between Them Froma conceptual point of view, TAOis an object-based timed concurrent constraint programmingtechnology, oriented to developmentof multi-agent systems. Let us consider howthis technology allows us to implement interactive, reactive, dynamicand intelligent behaviorof agents. First of all, wenotethat two mostimportantqualities of an agent are its autonomy and possibility of obtaining informationfromoutside (fromother agents and from the environment).Thefirst propertymeansthat the agentis in complete control of any changes in its state, and the secondimpliesthat this is doneon the basis of analysis of the surrounding reality. Object-based features of the TAOtechnology are displayed,in particular, in the representationof agentsin the form of a certain kind of persistent objects. These objects, which we will call active, have some nontraditional properties related both to their structure andto the wayof interaction. Active object has slots (attributes) of three kinds: external, internal, local. Externalslots are referencesto other active objects "visible" fromthis one. Internal slots characterizethe state of the object addare accessiblefrom outside (read-only access). Local slots are used for auxiliary purposes and cannot be accessed by other objects. Duringcomputationof its state an active object can use (as constants) the values of any internal slots ,U AI J/ A, ¯ ¯ .., I t ,U I II I I A7 Fig.1 Alink to the previous state is shownwith a dashed line, whilea link to the current state is representedby a solid line. Arrowsindicate the direction of dependence. For instance, the objects AI and A2are external for A4, i.e., it dependson them. In accordancewith the given graph,first of all wecompute in arbitrary order the states of the objects AI and A2, whichdo not dependon other 65 must be applied (this is whythe algorithm is called ’data-driven’). This algorithm makesit possible to find the only possible state of the active object (if it exists) or contract, to a certain extent, the domainsof values of variablesthat containall of the solutions. In the last case in order to choosesomedefinite state of the object weuse in addition methodsof backtrackingtype. So, wehaveconsideredhowthe paradigmof constraint programmingis used in TAOto describe interaction betweenagents and their behavior. This behavior maybe purelyreactive as well as rather intelligent, dependingon the complexityof the correspondingsystemof constraints. At the sametime, an intelligent agent mustperformsuch functionsas planning,forecasting, "look ahead,"etc. All these functions are somehowrelated to the notion of "time." Consider how TAOsupports time-dependent behaviorof agents. objects (we assumethat these are sensors), and of the object A3, whichdependsonly on the preceding (already known)state of the object AS. Next wecan computethe states of the objects A4and A5, and then finally A6, A7 and A8. Notethat solid arcs in the graphof relations of active objects cannot formcycles, since by the rules introduced above this would block the computation process. In practice this meansthat within one elementarystep one cannotrealize mutualdependence of objects¯ For instance, the situation A-->B-->A is impossible, since each of the objects will be waitinguntil the computationof the other one is completed. This situation maybe resolved in a correct manneras follows: 1) A--> B---> 2) A - - -> B --> 3) A- - -> B - - -> In the general case the followingrule can be stated: eachcycle inthe graphof relations of active objects should includeat least onedottedarc. Time in the Environment of Active Objects The progress of time is modeledin TAO with the help of an abstract clock, whichis representedby a special active object CLOCK that is external for all other active objects. This object is characterized, in particular, by the slots "now,"whichcontains the current time, and "max,"which limits the time of operation of the environment of active objects. Dependence of the behavior of an object on time means that its constraints are not active always, but only at certain times or in certain time intervals. Withaccess to the abstract clock, each object can makethe executionof its constraints dependenton absolute times. However,for an active object to be able to plan its actions it should workwith time as with a variable of a special kind. Supposethat the time data type represents one interval on the time axis and defines it via three attributes: beginning (beg), end (end) and length (In), whichare related bythe obviousrelation (In ffi end - beg + 1). We allow the values of any of these attributes to be known approximatelyand represented in the form of an integer interval. In particular, the values of attributes of a completelyunknown time variable are intervals whichin viewof the progressof time are definedas follows: beg, end= [xCLOCK.now,CLOCK.max]; in = [0, CLOCK.max - CLOCK.now + 1]. Eachtime variable (ti) is uniquelyassociated with a constraint(conditionalor unconditional),i.e., formula(1) takes the formt i : ci -~ r i. Atime-dependent constraint is executedonly if the current time belongsto the value of the correspondingtime variable. Computationswith time variables are described by special constraints, e.g., "t I starts after 3," "t 2 will continueat mostuntil 5," "t/is earlier than t2," "tI will occur5 steps after t2," "t I is not simultaneouswith t~," etc. Theseconstraints are part of the modelof the acttve object; they are solved jointly with the constraints computingits state. A time constraint can be conditional Computingthe State of an Active Object Considernowthe behaviorof an object, i.e. its transitions from one state to another. In TAO,the behavior of an object is given by a single modelrather than by a set of separate methodsor rules. Themodelis a conjunctionof constraints havingthe followingstructure: .... Cl’ ..... pn’,el r (Pl..... Pn,PI’, .... Pn’,el ..... em), (1) wherec is an ask-constraint,r is a tell-constraint, Pi are the object’sinternal slots, Pi’ are the valuesof slots of the object at the preceding step, ande:,J are the valuesof slots ¯ . of external objects. Beforethe computat,onof the current state all the Pi are assumedto be unknown andrepresented by the domainsof values. All the Pi’ andel. are assumed to be knownand cannot be changed. The left-hand side in (1) maybe absent. In. this case the tell-constraint is unconditionallytrue. If the ask-constraint producesthe valuetrue, then the corresponding tell-constraint is added to the set of unconditionally true constraints.Asa result of solving the set of all tell-constraints whichare currently true, wefind the state of the object. TAOadmits using different methodsto solve systems of constraints. For example,ff the modelof the object’s behavioris describedby a systemof linear equationsand inequalities, thenit is natural to solveit withthe simplexmethod.In the general case, however,TAO uses a certain universal algorithm of constraint propagation. This belongsto the class arc-consistencyandhas the following properties: 1) constraints are applied asynchronouslyin an arbitrary order, each constraint mustbe executedat least once, 2) application of constraints leads to monotone contractionof domainsof valuesof the variables, 3) if someconstraint changedthe value of somevariable "p", then all constraints for which"p" is a parameter 66 and maybe related to a proper time variable which controlsits periodsof activity. Solvingthe systemof time constraints, an active object at each time momentplans its future behavior and/or modifies a previously drawnplan. In view of this, we attract your attention to the followingcircumstance.In TAO,time variables have a different status comparedto the slots of an active object whichcharacterizeits state. If the latter are recomputedat each step, time-valued variables preserve their previously computedvalues. This semanticsenables us to continue in a natural mannerthe actions that havealready started andstart the scheduled actions on time. Consideran example.Supposethat by the time t = 10 the variables tl andt 2 are unknown and are related by the followingsystemof temporalconstraints: end(tl) < beg(t2); In (t1) ~ 3; end(t2) = 14. Solvingthis system,weobtain the following. t I = {beg-- [10,11], In = [3,4], end=[12,13]}, t 2 ,= {beg=[13,14],In ffi [1,2], end--14}. This solutionimplies, in particular, that someactionr1 related to the variabletl maystart at the currenttime or in the next step. To resolve this indefinite situation, the followingrule is assumedin TAO:an action is assumedto be started (completed) only if the attribute beg(end)of the correspondingtime variable has an exact value equal to the current time. Thus,the action rl will be started onlyat time t -- 11, whenthe variables tl and t 2 will haveexact values" t I ffi {beg= 11, In -- 3, end--13}, t 2 -- {beg= 14, in = 1, end= 14}. Thus, within a single system of constraints we can connectthe computationof the current state of an active objectwitha planOf its behavior. algorithm of UniCalcis close to tolerance propagation proposedindependentlyby E.Hyvonen (Hyvonen1992). contrast to the latter, it allows one, in particular, to combine in onesystemboth integer andreal variables. The .cuyrent version of TAO-Kitsupports mainly reactive behaviorof active objects, withoutanypossibility to plan it. Thedescriptionof an object has the following form: Object <name>: <prototype> ( Out<set of external objects>; In <set of slots>; Model<set of constraints> ) Considera concrete example.Supposethat an active object is a square, ’with sides parallel to the coordinate axes, whichautonomouslychangesits size dependingon the signals arriving fromthe mouse.Supposealso that in each step it movestwopositions alongthe Xaxis, until it reachesa fixed wall. Thenits descriptionlooksas follows: Example1. Objectact_square: square ( Out M: mouse; W: wall; In area : real; Model (M.rightffi true) &(~.lefl = true) edge-- edge’; (A£.right= true) &(A£.lefl =false) edgeffi edge’+ 1; ~.right =false) &’(l~.lefl = true)-> edge-- edge’ - 1; (M..right= false) &M.left ffi false) edge= edge’; area = edge"2; area < = 36; x =x’+ 2; x + edge < W.x; ) Herethe object ~square"is the prototypeof an active square (act_square), from whichthe latter inherits the slots "edge"(the size of an edge) and"x" (the coordinate of the top left angle). Note that weprefer the objectoriented mod~!of the "prototype-instance" kind to the moretraditional one, "class-instance." The active object "act_square" has two external objects; one of them(M)is the sensor connectedto external deviceof the type "mouse,"and the other (W) the constant object, a vertical line simulatinga wall. The identifiers Mand Ware in fact pointers to the values of external objects whosenamesmustbe concretized by the moment whenthis object is to be used. After the colon, we specify the nameof the prototype, whichmust belongto the list of the object’s ancestors,whichis substitutedfor the corresponding reference.: The object "act_square" specifies one more slot in addition to those inherited fromthe prototype-- "area," whichdenotesthe area of the square andis used to limit Implementation of TAO At present the TAOconcept is implementedin a agentbased languageTAO-Kit(Nesterenkoet al. 1996b), which is intendedto designgraphics applications. This language allowsoneto describea systemas a set of active graphics objects whichdynamicallychangetheir states interacting with each other and with. the environment.Theconnection with the environmentis provided by the special active objects (sensors) implementingaccess to devices like mouseand keyboard. Computationalcapabilities of the TAO-Kitlanguage are based on the use of the constraint solver of UniCalc (Babicbevet al. 1993). TheUniCalcsystem wasdesigned to solve arbitrary systemsof algebraicconstraints. Forthis program,a constraint is considered to be an equation, inequalityor a logical expression.Thesystemto be solved can be either overdeterminedor underdetermined,and the system’s parameters(coefficients and variables), can expressed as numerical intervals. The computation 67 its size. UnlikeMandW,the identifier "area" is a specific instanceof a number objvct, rather than a reference. The "main" part of a program in the TAOlanguage contains the creation of active objects, initialization and linking. For the examplein question, this part has the followingform: Example I (Continue). Initialization mouse; ConstWI: wall(x = 60; y = O; i = 50;); A1: act_square(edge = 1; x = 1; Consty = 5;); Linking AI (mouse, WI); End Whencreating an object, wecan set the initial values of someof its slots whichcorrespondto the time instant numbered0. The slots and objects whosevalues do not changein the entire computationprocess are labeled as constants. Thecomputations properstart at time instant 1. Undefinedslots initially havedefault or fully indefinite values. The"Linking"section specifies the relations between objects. Eachreference to a visible external object is assigned a concrete name.Here weconsider the simplest (static) case, whenall objects and relations are defined initially andpreservedtmtil the endof the computations. Todescribe the dynamiccreation/destructionof objects and the modificationof relations betweenthemthe special constraints connected with main programare used. The "ask"part of these constraintslooksas usual, but the "tell" part contains only the operationschangingthe structure of the environmentof active objects. The"main"constraints are executedat the end of each elementarystep whenthe current states of all active objectsare known. Considerthe interaction of active objects whichdepend on each other. Supposethat the wall in Example1 is not fixed, but movestowards the square. The process stops whenthe two objects meet. This leads to the following changesin the program.Thedescription of a newactive object "actwall" is added; the object "actsquare" becomesfor this object an external one. Somechangesare madeto the main program. Example2. Objectact_wall: wall (Out R : act_square; Model In this program,the object A 1 reacts to a changeof the state of the object W1within the current instant, whereas the object WIdetects a changeof the state of AI only at the nextinstant. Conclusion In this paper we proposea technologyof developmentof multi-agent system whoseoperational semanticsis based on the constraint programming paradigm. We can distinguish twofeatures of this paradigmthat determined our choice. Firstly, it enables us to describe complex, possibly"intelligent" behaviorof an agentat the highest level, as a modelwhichdefines in a declarative style all dependenciesbetweenthe agent’s parameters. Secondly, asynchronouscontrol of computations,whichis inherent in constraint programming, is the most appropriate mechanism for organizationof interaction betweenagents. Practical value of TAOis confirmed by its implementationin the TAO-Kit languagefor specification of graphics applications. In this languageeach graphics object is an independent agent whichcan dynamically changeits shapeandlocation, interacting in real time with other objects and external control devices. TAO-Kitis implementedusing the C++programminglanguagein the WindowsNToperating system. The current version of TAO-Kitsupports mainly the specification of reactive behavior of agents. Further development of this languageis related to the support of, "planning," "look-ahead," "goal-direoted" and other intelligentfeaturesof activeobjects. References Babichev, A.B., Semenov,A.L.; et al. 1993. UniCalc, A NovelApproachto Solving Systemsof Algebraic Equations. In PrOngs of the International Conference on NumericalAnalysis with AutomaticResult Verifications. Lafayette,Louisiana. Benhamou,F.; McAllester, D.; and Van HentemTck,P. 1994. CLP(Intervals) Revisited. In Proceedings ILPS’94,Ithaca, NY,USA:124-138. Colmerauer, A. 1990. An Introduction to Prolog IIL Communication of the A CM,33(7): 177-182. Dincbas, M.; VanHentenryck, P.; Simon;s, H.; Aggoun, A.; and Graf, T. 1988.Applicationsof CHIPto Industrial and EngineeringProblems. In Proceedingsof the First International ’Conferenceon Industrial and Engineering Applicationsof Artificial Intelligence andExpertSystems, Tallahoma, USA. Freeman-Benson, B. N., and Borning, A. 1992. Integrating Constraints with an Object -Oriented Language. Proceedings of the EuropeanConference on Object-Oriented Programming: 268-286. Henz, M.; Smolka,G.; and Wurtz,J. 1993. Object-Oriented Concurrent Constraint Programmingin Oz. DFKI ResearchReport RR-93-16,4. X = X’ ~ 1; R.x<fx; ) Initialization mouse; WI: act_wali(x= 60; Consty = O; 1 = 50;); AI: act_square(edge= 1; x = 1; Consty ffi 5;); Linking A1 (mouse, W1); wz(At’); End 68 Hyvonen, E. 1992. Constraint Reasoning Based on Interval Arithmetic: The Tolerance Propagation Approach. Artificial Intelligence, 58: 71-112. Mackworth,A.1977. Consistency in Networksof Relations. Artificial Intelligence,8" 99-118. Mackworth, A.K,. and Freuder, E.C. 1985. The Complexity of SomePolynomial network consistency algorithmfor ConstraintSatisfaction Problem.Artificial Intelligence25 (1)" 65-74. Malec,J. A. 1994..UnifiedApproachto Intelligent Agency. Research Report, LiTH-IDA-R-94-23,Linkoping University. Narin~ani,A.S. 1983.Subdefinitenessand basic meansof knowledgerepresentation . Computersand Artificial Intelligence, 2: 443-452. Narin~ani, A.S.; Borde, S.B.; and Ivanov, D.A. 1997. Subdefinite Mathematics and Novel Scheduling Technology.Artificial Intelligence in Engineenring11, Elsevier ScienceLimited. Nesterenko,T.; Starovit, S.; Titova, M.; and Shvetsov,I. 1996a. A Developmentof Multi-Agent Systems as Constraint Programming in Active Objects Environment. In Proceedings of V Rnssain Conferenceon Artificial Intelligence, 3:417-422,Kazan(in Russian). Nesterenko,T.; Starovit, S.; Titova, M.; andShvetsov,I. 1996b. TAO-Kit:Active Objects ProgrammingEnvironmet. TechnicalReport, 5, RussianResearchInst. of Art. Int, Novosibirsk (in Russian). Puget, J.-F., 1994. A C++Implementationof CLP.flog Solver Collectedpapers,Technicalreport. Sandewall, E. 1994. Features and Fluents. Oxford UniversityPress. Saraswat, V.A. 1993. Concurrent Constraint Programming. Logic Programming and Doctoral Dissertation AwardSeries. MITPress, 3. Saraswat, V.A., Jagadeesan, R., and Gupta, V. 1994. Foundations of Timed Concurrent Constraint Programming. In Proceedingsof LICS. Shvetsov, I.; Semenov,A.; and Telerman, V. 1995. Constraint ProgrammingBased on Subdefinite Models and Its Applications. In Proceedingsof International Logic ProgrammingSymposium,Workshopon Interval Constraints, Portland, Oregon. Shvetsov, I.; Semenov,A.; and Telerman, V. 1997. Application of Subdefinite Models in Engineering. Artificial Intelligence in Engineenring11, Elsevier ScienceLimited. 69