public class Policy extends Object implements AbstractPolicy
Modifier and Type | Class and Description |
---|---|
static class |
Policy.OpType
The kinds of Social Commitment Operators that can be specified
|
(package private) static class |
Policy.SCOpData |
Modifier and Type | Field and Description |
---|---|
private EventDescriptor |
antecedent |
private static CasaLispOperator |
CONSEQUENT_CLASS
Lisp operator: (POLICY event-descriptor '(action ...))
Construct a Policy object and add it to the agent's policy store. |
private List<PolicyConsequentInterface> |
consequents |
(package private) String |
doc |
private boolean |
ghost |
private int |
id |
private static int |
idSequence |
private String |
name |
private static CasaLispOperator |
POLICY
Lisp operator: (POLICY event-descriptor '(action ...))
Construct a Policy object and add it to the agent's policy store. |
private Cons |
postcondition |
private Cons |
precondition |
private static CasaLispOperator |
SC__ADD
Lisp operator: (ADD :DEBTOR d :Creditor c :PERFORMATIVE p :ACT ...)
Construct a social commitment ADD operator. |
private static CasaLispOperator |
SC__CANCEL
Lisp operator: (CANCEL :DEBTOR d :Creditor c :PERFORMATIVE p :ACT a)
Construct a social commitment CANCEL operator. |
private static CasaLispOperator |
SC__FULFIL
Lisp operator: (FULFIL :DEBTOR d :Creditor c :PERFORMATIVE p :ACT a)
Construct a social commitment FULFIL operator. |
private String |
sourceFile |
private Cons |
unevaluatedAntecedent |
Constructor and Description |
---|
Policy()
Constructs a new Policy
|
Modifier and Type | Method and Description |
---|---|
StatusObject<List<Object>> |
apply(PolicyAgentInterface agent,
Status status,
Vector<AbstractPolicy> policyContext,
Event event,
Map<String,LispObject> map,
Object eventInstanceInfo) |
Policy |
clone() |
int |
compareTo(AbstractPolicy o) |
private static String |
ConsToStringWithoutInterp(Cons cons) |
private boolean |
evalBooleanExpression(PolicyAgentInterface agent,
Cons exp,
Map<String,LispObject> map) |
private Object |
evalExpression(PolicyAgentInterface agent,
Cons exp,
Map<String,LispObject> map) |
protected StatusObject<List<Object>> |
executeConcequent(PolicyAgentInterface agent,
Status status,
Vector<AbstractPolicy> policyContext,
Event event,
Object eventInstanceInfo,
Map<String,LispObject> map) |
private static Condition |
getAddifParam1(Cons cons) |
EventDescriptor |
getAntecedent() |
List<PolicyConsequentInterface> |
getConsequents()
get method for this policy's consequents
|
String |
getDoc() |
int |
getID() |
String |
getName()
Equivalent to getName(false)
|
String |
getName(boolean longVersion)
Returns either the long or short form of the name.
short form:name long form: name ({performative|*}:{act|*}) |
Cons |
getPostcondition() |
Cons |
getPrecondition() |
private static Policy.SCOpData |
getSCOpData(String op,
TransientAgent agent,
ParamsMap params,
Environment env) |
String |
getSourceFile() |
String |
getType() |
Cons |
getUnevaluatedAntecedent() |
Status |
isApplicable(PolicyAgentInterface agent,
Event event,
Map<String,LispObject> map)
Determines if this policy is applicable to the event.
|
boolean |
isGhost()
A ghost policy is a policy that shouldn't be counted as being applied.
|
void |
setAntecedent(EventDescriptor antecedent) |
void |
setAntecedent(String antecedent) |
void |
setConsequents(List<PolicyConsequentInterface> consequents)
allows for the setting of consequents using a list of PolicyConsequentInterface(s)
|
void |
setConsequentsByStrings(List<String> consequents)
allows for setting consequents using a list of Strings
|
protected void |
setDoc(String doc) |
void |
setGhost()
Declares this policy a ghost.
|
void |
setName(String name) |
void |
setPostcondition(Cons postcondition) |
void |
setPostcondition(String postcondition) |
void |
setPrecondition(Cons precondition) |
void |
setPrecondition(String precondition) |
void |
setSourceFile(String s) |
protected void |
setUnevaluatedAntecedent(Cons eventDescriptorCons) |
private Cons |
toCons(String precondition) |
String |
toString() |
String |
toString(int indent) |
String |
toStringUML() |
Object |
updateAntecedent(PolicyAgentInterface agent,
Map<String,LispObject> map)
if there is an unevaluated antecedent, and the evaluation is a
EventDescriptor
then place this EventDescriptor in the antecedent. |
private static int idSequence
private int id
String doc
private String sourceFile
private String name
private EventDescriptor antecedent
private Cons unevaluatedAntecedent
private Cons precondition
private Cons postcondition
private List<PolicyConsequentInterface> consequents
private boolean ghost
isGhost()
private static final CasaLispOperator POLICY
private static final CasaLispOperator CONSEQUENT_CLASS
private static final CasaLispOperator SC__ADD
private static final CasaLispOperator SC__FULFIL
private static final CasaLispOperator SC__CANCEL
public Policy()
type
- the type (or category) of the policyname
- the type of the individual policypublic void setSourceFile(String s)
setSourceFile
in interface AbstractPolicy
public String getSourceFile()
getSourceFile
in interface AbstractPolicy
public void setName(String name)
public void setAntecedent(EventDescriptor antecedent)
public void setAntecedent(String antecedent)
public EventDescriptor getAntecedent()
getAntecedent
in interface AbstractPolicy
protected void setUnevaluatedAntecedent(Cons eventDescriptorCons)
public Cons getUnevaluatedAntecedent()
public Cons getPrecondition()
public void setPrecondition(Cons precondition)
public void setPrecondition(String precondition) throws IllegalArgumentException
IllegalArgumentException
private Cons toCons(String precondition) throws IllegalArgumentException
IllegalArgumentException
public Cons getPostcondition()
public void setPostcondition(Cons postcondition)
public void setPostcondition(String postcondition)
public void setConsequents(List<PolicyConsequentInterface> consequents)
consequents
- the list of consequents as a list of PolicyConsequentInterface(s)public void setConsequentsByStrings(List<String> consequents)
consequents
- the list of consequents as stringspublic List<PolicyConsequentInterface> getConsequents()
public boolean isGhost()
isGhost
in interface AbstractPolicy
public void setGhost()
setGhost
in interface AbstractPolicy
isGhost()
public Policy clone()
clone
in interface AbstractPolicy
clone
in class Object
public String getName(boolean longVersion)
AbstractPolicy
short form: | name |
long form: | name ({performative|*}:{act|*}) |
getName
in interface AbstractPolicy
longVersion
- public String getName()
AbstractPolicy
getName
in interface AbstractPolicy
public String getDoc()
getDoc
in interface AbstractPolicy
protected void setDoc(String doc)
doc
- set the documenation string for this objectpublic int getID()
getID
in interface AbstractPolicy
public String toString()
toString
in interface AbstractPolicy
toString
in class Object
Object.toString()
public String toString(int indent)
toString
in interface AbstractPolicy
Object.toString()
public String toStringUML()
public int compareTo(AbstractPolicy o)
compareTo
in interface Comparable<AbstractPolicy>
public String getType()
getType
in interface AbstractPolicy
public final StatusObject<List<Object>> apply(PolicyAgentInterface agent, Status status, Vector<AbstractPolicy> policyContext, Event event, Map<String,LispObject> map, Object eventInstanceInfo) throws Exception, Throwable
apply
in interface AbstractPolicy
Exception
Throwable
public Status isApplicable(PolicyAgentInterface agent, Event event, Map<String,LispObject> map)
EventDescriptor
, which returns false for
this event, the event is considered NOT applicable and we return false.
Cons
, it is evaluated.
If it returns a EventDescriptor
, this is evaluated as in (1), otherwise the
Cons is evaluated as if it were a lisp boolean expression. If the expression returns
NIL, the event is considered NOT applicable and we return false.
isApplicable
in interface AbstractPolicy
agent
- The agent in who's context the policy is to be executed inevent
- The eventmap
- The mapping of symbols to be added to the lisp envirnonmentAbstractPolicy.isApplicable(casa.interfaces.PolicyAgentInterface, casa.event.Event, java.util.Map)
public Object updateAntecedent(PolicyAgentInterface agent, Map<String,LispObject> map)
EventDescriptor
then place this EventDescriptor
in the antecedent. The return
value is not particularly meaningful, but it can be used to avoid performing
the evaluation multiple times as it is guaranteed to be the result of an
evaluation of the unevaluated antecedent if there is one.updateAntecedent
in interface AbstractPolicy
agent
- map
- symbols to be placed in the lisp environment during any evaluation.private Object evalExpression(PolicyAgentInterface agent, Cons exp, Map<String,LispObject> map)
private boolean evalBooleanExpression(PolicyAgentInterface agent, Cons exp, Map<String,LispObject> map)
protected StatusObject<List<Object>> executeConcequent(PolicyAgentInterface agent, Status status, Vector<AbstractPolicy> policyContext, Event event, Object eventInstanceInfo, Map<String,LispObject> map) throws Exception, ControlTransfer
Exception
ControlTransfer
private static Policy.SCOpData getSCOpData(String op, TransientAgent agent, ParamsMap params, Environment env) throws ControlTransfer, Exception
ControlTransfer
Exception
private static Condition getAddifParam1(Cons cons) throws LispParseException
cons
- LispParseException