last = new AndConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])); else last = new OrConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])); ret.add(new AndConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()]))); else ret.add(new OrConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])));
List cs = ac.getConstraints(); List evas = new ArrayList(); for(int i=0; i<cs.size(); i++)
last = new AndConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])); else last = new OrConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])); ret.add(new AndConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()]))); else ret.add(new OrConstraint((IConstraint[])consts.toArray(new IConstraint[consts.size()])));
List cs = ac.getConstraints(); List evas = new ArrayList(); for(int i=0; i<cs.size(); i++)
IConstraint msgrec = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_MESSAGEEVENTRECEIVED); IConstraint msgsent = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_MESSAGEEVENTSENT); cecon.addConstraint(new OrConstraint(new IConstraint[]{msgrec, msgsent})); cecon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.changeevent_has_element, revent)); cecon.addConstraint(new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.changeevent_has_element, OAVBDIRuntimeModel.element_has_model}, mevent)); IConstraint relme = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, mevent, IOperator.CONTAINS); IConstraint relre = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, revent, IOperator.CONTAINS); liscon.addConstraint(new OrConstraint(new IConstraint[]{relme, relre}));
IConstraint c1 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_internalevents, rpe, IOperator.CONTAINS); IConstraint c2 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_messageevents, rpe, IOperator.CONTAINS); capcon.addConstraint(new OrConstraint(new IConstraint[]{c1, c2})); IConstraint co1 = new BoundConstraint(OAVBDIRuntimeModel.waitabstraction_has_internaleventtypes, mpe, IOperator.CONTAINS); IConstraint co2 = new BoundConstraint(OAVBDIRuntimeModel.waitabstraction_has_messageeventtypes, mpe, IOperator.CONTAINS); wacon.addConstraint(new OrConstraint(new IConstraint[]{co1, co2}));
IConstraint msgrec = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_PLANADDED); IConstraint msgsent = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_PLANREMOVED); cecon.addConstraint(new OrConstraint(new IConstraint[]{msgrec, msgsent})); cecon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.changeevent_has_element, rplan)); cecon.addConstraint(new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.changeevent_has_element, OAVBDIRuntimeModel.element_has_model}, mplan)); IConstraint relme = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, mplan, IOperator.CONTAINS); IConstraint relre = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, rplan, IOperator.CONTAINS); liscon.addConstraint(new OrConstraint(new IConstraint[]{relme, relre}));
IConstraint msgrec = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_GOALADDED); IConstraint msgsent = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_GOALDROPPED); cecon.addConstraint(new OrConstraint(new IConstraint[]{msgrec, msgsent})); cecon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.changeevent_has_element, rgoal)); cecon.addConstraint(new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.changeevent_has_element, OAVBDIRuntimeModel.element_has_model}, mgoal)); IConstraint relme = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, mgoal, IOperator.CONTAINS); IConstraint relre = new BoundConstraint(OAVBDIRuntimeModel.listenerentry_has_relevants, rgoal, IOperator.CONTAINS); liscon.addConstraint(new OrConstraint(new IConstraint[]{relme, relre}));
IConstraint aplnull = new LiteralConstraint(OAVBDIRuntimeModel.processableelement_has_apl, null, IOperator.EQUAL); IConstraint notretry = new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.goal_has_retry}, Boolean.FALSE); goalcon.addConstraint(new AndConstraint(new IConstraint[]{notrecur, new OrConstraint(new IConstraint[]{notretry, new AndConstraint(new IConstraint[]{notreb, aplnull})})}));
IConstraint co2a = new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.plan_has_waitabstraction, OAVBDIRuntimeModel.waitabstraction_has_goals}, rgoal, IOperator.EXCLUDES); IConstraint co2b = new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.plan_has_waitabstraction, OAVBDIRuntimeModel.waitabstraction_has_goalfinisheds}, mgoal, IOperator.EXCLUDES); plancon.addConstraint(new OrConstraint(co1, new AndConstraint(co2a, co2b))); plancon.addConstraint(new BoundConstraint(null, rplans, IOperator.EXCLUDES)); plancon.addConstraint(new OrConstraint(co3, co4));
goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_ACTIVE, IOperator.NOTEQUAL)); OrConstraint statecon = new OrConstraint(new IConstraint[]{ new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_INPROCESS), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_PAUSED)
/** * Start dropping a goal that is succeeded or failed. */ public static Rule createGoalDroppingRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable mgoal = new Variable("?mgoal", OAVBDIMetaModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.element_has_model, mgoal)); goalcon.addConstraint(new AndConstraint( new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPING, IOperator.NOTEQUAL), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPED, IOperator.NOTEQUAL))); goalcon.addConstraint(new OrConstraint( new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_SUCCEEDED), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_FAILED))); // goalcon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVAttributeType.OBJECTTYPE}, OAVBDIMetaModel.maintaingoal_type, IOperator.NOTEQUAL)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); // Hack!!! Higher priority required to avoid deliberation activating goal that is already finished in option state (e.g. due to immediately fulfilled target condition) Rule goal_dropping = new Rule("goal_dropping", new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_DROPPING_ACTION, IPriorityEvaluator.PRIORITY_1); return goal_dropping; }
rplancon.addConstraint(new OrConstraint(new IConstraint[]{co1, co2}));
rplancon.addConstraint(new OrConstraint(new IConstraint[]{co1, co2}));
rplancon.addConstraint(new OrConstraint(new IConstraint[]{co1, co2}));
IConstraint con1 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rpe, IOperator.CONTAINS); IConstraint con2 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rpe, IOperator.CONTAINS); rcapacon.addConstraint(new OrConstraint(new IConstraint[]{con1, con2}));
IConstraint co1 = new BoundConstraint(OAVBDIRuntimeModel.waitabstraction_has_goals, rpe, IOperator.CONTAINS); IConstraint co2 = new BoundConstraint(OAVBDIRuntimeModel.waitabstraction_has_goalfinisheds, mpe, IOperator.CONTAINS); wacon.addConstraint(new OrConstraint(new IConstraint[]{co1, co2}));
IConstraint rebapl = new AndConstraint(new IConstraint[]{new LiteralConstraint(OAVBDIRuntimeModel.processableelement_has_apl, null, IOperator.EQUAL), new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.goal_has_rebuild}, Boolean.FALSE)}); IConstraint nomoreplan = new OrConstraint(new IConstraint[]{new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.goal_has_retry}, Boolean.FALSE), rebapl}); goalcon.addConstraint(nomoreplan); goalcon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.goal_has_recur}, Boolean.FALSE)); IConstraint planfail = new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_FAILED); IConstraint planabort = new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_ABORTED); plancon.addConstraint(new OrConstraint(new IConstraint[]{goalhastarget, planfail, planabort}));
IConstraint con1 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rpe, IOperator.CONTAINS); IConstraint con2 = new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rpe, IOperator.CONTAINS); rcapacon.addConstraint(new OrConstraint(new IConstraint[]{con1, con2}));
IConstraint rem = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_FACTREMOVED); IConstraint change = new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_FACTCHANGED); cecon.addConstraint(new OrConstraint(new IConstraint[]{add, rem, change})); cecon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.changeevent_has_element, rbeliefset)); cecon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_element, OAVBDIRuntimeModel.beliefset_type, IOperator.INSTANCEOF));