gov.nasa.arc.brahms.vm.data
Class VMObjectComparison

java.lang.Object
  extended by gov.nasa.arc.brahms.common.data.BrahmsObject
      extended by gov.nasa.arc.brahms.common.data.Comparison
          extended by gov.nasa.arc.brahms.common.data.ObjectComparison
              extended by gov.nasa.arc.brahms.vm.data.VMObjectComparison
All Implemented Interfaces:
gov.nasa.arc.brahms.common.IConstants, IVMComparison, java.io.Serializable

public class VMObjectComparison
extends ObjectComparison
implements IVMComparison

The VMObjectComparison is an ObjectComparison with extensions for use in the virtual machine. An object comparison specified a relationship between two objects using a user specified relation.

Version:
$Revision: 1.9 $ $Date: 2009/11/23 22:24:32 $ $Author: rnado $
Author:
Ron van Hoof
See Also:
ObjectComparison, VMExpression, Serialized Form

Field Summary
 
Fields inherited from interface gov.nasa.arc.brahms.vm.data.IVMComparison
BELIEFS, FACTS, NONE
 
Fields inherited from interface gov.nasa.arc.brahms.common.IConstants
ABORT, ACTIVECLASS, ACTIVECONCEPT, ACTIVEINSTANCE, AGENT, ANONYMOUS, ANYAGENT, AREA, AREADEF, ASSIGNED, ATTRIBUTE, BASEAREADEF, BASECLASS, BASECONCEPTUALCLASS, BASEGROUP, BASELIBRARY, BOOLEAN, BROADCAST, BUILDING, BYTE, CCLOCK, CDATE, CHAR, CITY, CLASS, CLOCK, COLLECTALL, COMMUNICATE, COMPLETE, COMPOSITE, COMPUTER, CONCEPT, CONCEPTUALCLASS, CONCEPTUALCONCEPT, CONCEPTUALOBJECT, CONTINUE, COPY, CREATEAGENT, CREATEAREA, CREATEOBJECT, current, CURRENT, DATAFRAME, DATE, DB, DETECTABLE, DIV, DOUBLE, EMAIL, EMPTY_STRING, END, ENDACTIVITY, ENTAGENT, EQ, EXCEPTION, EXPR, FACE2FACE, FACTFRAME, FALSE, FAX, FLOAT, FOREACH, FORONE, G2, GE, GEOGRAPHYCONCEPT, GESTURE, GET, GROUP, GT, IMPASSE, INT, INVALID, JAVA, JAVA_TYPE, KNOWN_MODIFIER, KNOWNVAL_MODIFIER, LE, LOCAL, LONG, LT, MAP, MINUS, MOD, MOVE, MULT, NE, NEW, NONE, NOT_MODIFIER, NOWORK, O, OA, OBJECT, ONTOLOGY, PAGER, PARAMETER, PATH, PHONE, PLUS, PRIMITIVE, PRIVATE, PROAGENT, PROTECTED, PRSAGENT, PUBLIC, PUT, RECEIVE, RELATION, sACTIVECLASS, sACTIVECONCEPT, sACTIVEINSTANCE, sAGENT, sARCHIVE, sAREA, sAREADEF, sBOOLEAN, sBYTE, sBYTECODEEXT, sCHAR, sCLASS, sCOMPUTER, sCONCEPT, sCONCEPTUALCLASS, sCONCEPTUALCONCEPT, sCONCEPTUALOBJECT, sCOPY, sCURRENT, sDETECTABLE, sDOUBLE, sEMAIL, sEND, SEND, sFACE2FACE, sFAX, sFILEEXT, sFLOAT, sGEOGRAPHYCONCEPT, sGROUP, SHORT, SIMAGENT, sINT, sJAVA_TYPE, sLONG, sMAP, sNEW, sNONE, sNOWORK, sOBJECT, SOURCECODE, sPAGER, sPARAMETER, sPATH, sPHONE, sPRIVATE, sPROJECTEXT, sPROTECTED, sPUBLIC, sSHORT, sSTART, sSTRING, sSYMBOL, START, STRING, sUNKNOWN, sVOID, SYMBOL, TRUE, UDT, UML, UNASSIGNED, UNDEFINED, unknown, UNKNOWN, UNKNOWN_MODIFIER, V, VARIABLE, VOID, WHENEVER, WORKFRAME, WORLD, XML
 
Constructor Summary
VMObjectComparison()
          Constructor, creates a new object comparison
VMObjectComparison(VMExpression lhs, Relation relation, VMExpression rhs)
          Constructor, creates a new object comparison with the specified left hand side expression, relational operator and right hand side expression.
 
Method Summary
 void buildRSN(gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork rsn, gov.nasa.arc.brahms.vm.engine.rsn.IRSNFrameNode frame, gov.nasa.arc.brahms.vm.engine.rsn.RSNActivityRefNode actref, int modifier)
          Adds this comparison to the reasoning state network to build up a reasoning state network that maintains a state of what statements matched with the comparison.
 boolean evaluate(gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame, int modifier, int truthvalue, gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameEvaluationRecord evalRcd)
          Evaluates the comparison as part of a precondition determining whether or not the comparison has a successfull match with a statement.
 java.util.LinkedList getConcludingStatements(VMActiveInstanceCtx agent, VMFrameCtx frame, boolean updateJava)
          Matches the comparison with the belief set of the specified agent and creates the statements that would result from the comparison after the match.
 java.util.LinkedList getDetectableFacts(VMActiveInstanceCtx agent, VMFrameCtx frame)
          Matches the comparison with the fact set of the world and returns the statements that match with the left hand side of the comparison after resolving the left hand side.
 java.util.LinkedList getTransferableCommunicativeActs(VMActiveInstanceCtx agent, VMFrameCtx frame)
          Resolves the CommunicativeAct specified for the transfer definition to the (list of) CommunicativeAct(s) to be transferred.
 java.util.LinkedList getTransferableStatements(VMActiveInstanceCtx agent, VMFrameCtx frame, int truthvalue)
          Matches the comparison of a transfer definition with the belief set of the specified agent and returns the statements that match with the comparison after resolving the lhs and rhs.
 VMBeliefCtx hasTriggeringBelief(VMActiveInstanceCtx agent, VMFrameCtx frame, int truthvalue)
          Checks whether the specified agent has a belief that can activate the trigger for which this comparison is the condition.
 boolean isDetectableFact(VMFactCtx fact, VMActiveInstanceCtx agent, VMFrameCtx frame)
          Checks whether the specified fact can be detected by matching the fact against the left hand side of the comparison.
 boolean isTriggeringBelief(VMBeliefCtx belief, VMActiveInstanceCtx agent, VMFrameCtx frame, int truthvalue)
          Checks whether the specified belief can cause the activation of the trigger by matching the belief against the comparison.
 
Methods inherited from class gov.nasa.arc.brahms.common.data.ObjectComparison
getRelation, setRelation, toString
 
Methods inherited from class gov.nasa.arc.brahms.common.data.Comparison
getLhs, getParameters, getRhs, getVariables, setLhs, setRhs
 
Methods inherited from class gov.nasa.arc.brahms.common.data.BrahmsObject
delete, export, getFile, getID, getLine, getSerialNumber, isBCC, isDynamic, isLoaded, isResolved, setBCC, setDynamic, setFile, setID, setID, setLine, setLoaded, setResolved, setSerialNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VMObjectComparison

public VMObjectComparison()
Constructor, creates a new object comparison


VMObjectComparison

public VMObjectComparison(VMExpression lhs,
                          Relation relation,
                          VMExpression rhs)
Constructor, creates a new object comparison with the specified left hand side expression, relational operator and right hand side expression.

Parameters:
lhs - the left hand side Expression
relation - the user defined Relation
rhs - the right hand side Expression
See Also:
VMExpression
Method Detail

getConcludingStatements

public java.util.LinkedList getConcludingStatements(VMActiveInstanceCtx agent,
                                                    VMFrameCtx frame,
                                                    boolean updateJava)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Matches the comparison with the belief set of the specified agent and creates the statements that would result from the comparison after the match. If also the fact set is to be used (includeFacts = true) then the comparison is also matched with the facts in the fact set and statements are created that would result from the comparison after the match.

The comparison serves as an assignment where the rhs is matched and resolved and new statements are created preserving the left hand side and assigning it the value(s) matched on the right hand side. On the left hand side only the object is resolved to concepts if instead of a concept, current, a variable or a parameter is specified.

Note:This method is only usable with consequences, not with detectables, transfer definitions and preconditions. Left hand side of preconditions can contain expressions which are not handled by this method. Transfer definitions and detectables require rhs matching and not assignment.

Specified by:
getConcludingStatements in interface IVMComparison
Parameters:
agent - the agent with whom's belief set we need to match
frame - the frame containing variable contexts for variables used by the comparison.
updateJava - whether to update Java objects as a side effect of determining the concluded statements
Returns:
LinkedList containing a list of Statements resulting from the comparison
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model

getTransferableCommunicativeActs

public java.util.LinkedList getTransferableCommunicativeActs(VMActiveInstanceCtx agent,
                                                             VMFrameCtx frame)
                                                      throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Resolves the CommunicativeAct specified for the transfer definition to the (list of) CommunicativeAct(s) to be transferred.

Specified by:
getTransferableCommunicativeActs in interface IVMComparison
Parameters:
agent - the agent initiating the communication
frame - the frame containing variable contexts for variables used by the comparison.
Returns:
LinkedList containing a list of VMObjectCtx for the matching CommunicativeActs
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model

getTransferableStatements

public java.util.LinkedList getTransferableStatements(VMActiveInstanceCtx agent,
                                                      VMFrameCtx frame,
                                                      int truthvalue)
                                               throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Matches the comparison of a transfer definition with the belief set of the specified agent and returns the statements that match with the comparison after resolving the lhs and rhs.

Specified by:
getTransferableStatements in interface IVMComparison
Parameters:
agent - the agent with whom's belief set we need to match
frame - the frame containing variable contexts for variables used by the comparison.
truthvalue - the truth value of the comparison (TRUE, FALSE, UNKNOWN)
Returns:
LinkedList containing a list of VMBeliefCtx matching with the comparison
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN

getDetectableFacts

public java.util.LinkedList getDetectableFacts(VMActiveInstanceCtx agent,
                                               VMFrameCtx frame)
                                        throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Matches the comparison with the fact set of the world and returns the statements that match with the left hand side of the comparison after resolving the left hand side.

Note:This method is only usable with detectables as it limits the matching to facts in the world and only matches against the left hand side.

Specified by:
getDetectableFacts in interface IVMComparison
Parameters:
agent - the agent that is checking for detection
frame - the frame containing variable contexts for variables used by the comparison.
Returns:
LinkedList containing a list of VMFactCtx matching with the comparison
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model

isDetectableFact

public boolean isDetectableFact(VMFactCtx fact,
                                VMActiveInstanceCtx agent,
                                VMFrameCtx frame)
                         throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Checks whether the specified fact can be detected by matching the fact against the left hand side of the comparison. If the fact matches, the fact can be detected and true is returned, otherwise false is returned.

Specified by:
isDetectableFact in interface IVMComparison
Parameters:
fact - the VMFactCtx for the fact to be checked for detection
agent - the agent that is checking for detection
frame - the frame containing variable contexts for variables used by the comparison.
Returns:
true if the fact matches the comparison and can be detected, false otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model

hasTriggeringBelief

public VMBeliefCtx hasTriggeringBelief(VMActiveInstanceCtx agent,
                                       VMFrameCtx frame,
                                       int truthvalue)
                                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Checks whether the specified agent has a belief that can activate the trigger for which this comparison is the condition. If the agent has a belief that matches the comparison then true is returned, otherwise false is returned.

Specified by:
hasTriggeringBelief in interface IVMComparison
Parameters:
agent - the agent that is checking the trigger and whom's belief set is checked for a matching belief
frame - the frame containing variable contexts for variables used by the comparison.
truthvalue - the specified truth value of the detectable condition (TRUE, FALSE, UNKNOWN)
Returns:
VMBeliefCtx the belief that matches the comparison and can activate the trigger, null of no belief matches the comparison
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN

isTriggeringBelief

public boolean isTriggeringBelief(VMBeliefCtx belief,
                                  VMActiveInstanceCtx agent,
                                  VMFrameCtx frame,
                                  int truthvalue)
                           throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Checks whether the specified belief can cause the activation of the trigger by matching the belief against the comparison. If the belief matches, the belief can activate the trigger and true is returned, otherwise false is returned.

Specified by:
isTriggeringBelief in interface IVMComparison
Parameters:
belief - the VMBeliefCtx for the belief to be checked for trigger activation
agent - the agent that is checking the trigger
frame - the frame containing variable contexts for variables used by the comparison.
truthvalue - the specified truth value of the detectable condition (TRUE, FALSE, UNKNOWN)
Returns:
true if the belief matches the comparison and can activate the trigger, false otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in retrieving information from the static or dynamic model
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN

buildRSN

public void buildRSN(gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork rsn,
                     gov.nasa.arc.brahms.vm.engine.rsn.IRSNFrameNode frame,
                     gov.nasa.arc.brahms.vm.engine.rsn.RSNActivityRefNode actref,
                     int modifier)
              throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds this comparison to the reasoning state network to build up a reasoning state network that maintains a state of what statements matched with the comparison.

Specified by:
buildRSN in interface IVMComparison
Parameters:
rsn - the ReasoningStateNetwork to be built
frame - the RSNFrameNode for the frame in which this comparison is used.
actref - the optional RSNActivityRefNode for the activity reference referencing a composite activity in which the frame and the precondition are specified.
modifier - the modifier of the (pre)condition
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in building up the RSN with this comparison

evaluate

public boolean evaluate(gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame,
                        int modifier,
                        int truthvalue,
                        gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameEvaluationRecord evalRcd)
                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Evaluates the comparison as part of a precondition determining whether or not the comparison has a successfull match with a statement. If so the comparison evaluates to true.

Specified by:
evaluate in interface IVMComparison
Parameters:
frame - the RSNFrameNode for the frame in which the comparison's precondition is specified
modifier - the modifier of the (pre)condition
truthvalue - the truth value of the (pre)condition (TRUE, FALSE, UNKNOWN)
evalRcd - the record in which to store bindings for variables and statements matching preconditions
Returns:
true if the comparison evaluates to true, false otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN


Copyright © 1997-2012 All Rights Reserved.