Exemplo n.º 1
0
def test_shouldBeUnachievable():

    root = Goal(Decomposition.AND)

    context1 = Context("c1")
    context2 = Context("c2")

    current = []
    current.append(context1)

    task1 = Task()

    task2 = Task()

    task1.addApplicableContext(context2)
    task2.addApplicableContext(context2)

    root.addDependency(task1)
    root.addDependency(task2)

    deps = []
    deps.append(task1)
    deps.append(task2)

    plan = root.isAchievable(current, None)

    assert plan is None
Exemplo n.º 2
0
def test_refinement():
    refinement = Refinement()
    task = Task()
    delegation = Delegation()
    goal = Goal(Decomposition.AND)

    assert task.myType() is refinement.TASK
    assert delegation.myType() is refinement.DELEGATION
    assert goal.myType() is refinement.GOAL
Exemplo n.º 3
0
def test_aGoalOrDecomposedWithTwoTasksMayNotBeAchievable():
    goal = Goal(Decomposition.OR)

    task1 = Task()
    task2 = Task()
    current = Context("C1")
    fullContext = []
    fullContext.append(current)

    qc = QualityConstraint(current, CommonMetrics.SECONDS, 15,
                           Comparison.LESS_OR_EQUAL_TO)

    task1.addApplicableContext(current)
    task1.setProvidedQuality(current, CommonMetrics.SECONDS, 16)

    task2.addApplicableContext(current)
    task2.setProvidedQuality(current, CommonMetrics.SECONDS, 17)

    goal.addDependency(task1)
    goal.addDependency(task2)

    goal.setIdentifier("Root")
    goal.addApplicableContext(current)

    interp = Interpretation()
    interp.addQualityConstraint(qc)

    plan = goal.isAchievable(fullContext, interp)
    assert goal.decomposition is Decomposition.OR
    assert plan is None
Exemplo n.º 4
0
def test_aGoalAndDecomposedWithTwoTasksMayBeAchievable():
    goal = Goal(Decomposition.AND)

    task1 = Task()
    task2 = Task()

    current = Context("C1")
    fullContext = []
    fullContext.append(current)

    qc = QualityConstraint(current, CommonMetrics.SECONDS, 15,
                           Comparison.LESS_OR_EQUAL_TO)

    interp = Interpretation()
    interp.addQualityConstraint(qc)

    task1.addApplicableContext(current)
    task1.setProvidedQuality(current, CommonMetrics.SECONDS, 13)

    task2.addApplicableContext(current)
    task2.setProvidedQuality(current, CommonMetrics.SECONDS, 11)

    goal.addDependency(task1)
    goal.addDependency(task2)

    goal.setIdentifier("Root")
    goal.addApplicableContext(current)

    plan = goal.isAchievable(fullContext, interp)
    assert 2 == len(plan.getTasks())
Exemplo n.º 5
0
def test_aNonApplicableRootGoalIsNotAchievable():
    goal = Goal(Decomposition.AND)
    current = Context("C1")
    fullContext = []

    qc = QualityConstraint(current, CommonMetrics.SECONDS, 15,
                           Comparison.LESS_OR_EQUAL_TO)
    goal.addApplicableContext(Context("C2"))

    interp = Interpretation()
    interp.addQualityConstraint(qc)

    assert goal.isAchievable(fullContext, interp) is None
Exemplo n.º 6
0
def test_shouldBeApplicable():
    goal = Goal(Decomposition.AND)
    task = Task()
    delegation = Delegation()

    contextCurrent = Context("C1")
    fullContext = []

    fullContext.append(contextCurrent)

    goal.addApplicableContext(contextCurrent)
    task.addApplicableContext(contextCurrent)
    delegation.addApplicableContext(contextCurrent)

    assert True is goal.isApplicable(fullContext)
    assert True is task.isApplicable(fullContext)
    assert True is delegation.isApplicable(fullContext)
Exemplo n.º 7
0
def test_shouldBeAchievable():
    root = Goal(Decomposition.AND, "root")

    context = Context("c1")
    current = []
    current.append(context)

    task1 = Task("t1")
    task2 = Task("t2")

    task1.addApplicableContext(context)

    root.addDependency(task1)
    root.addDependency(task2)

    plan = root.isAchievable(current, None)
    assert plan

    assert task2 in plan.getTasks()
Exemplo n.º 8
0
def test_shouldBeNotApplicable():
    goal = Goal(Decomposition.AND)
    task = Task()
    delegation = Delegation()

    context = Context("C1")

    task.addApplicableContext(context)

    goal.addApplicableContext(context)

    delegation.addApplicableContext(context)

    wrongContext = Context("C2")
    fullContext = []
    fullContext.append(wrongContext)

    assert False is goal.isApplicable(fullContext)
    assert False is task.isApplicable(fullContext)
    assert False is delegation.isApplicable(fullContext)
Exemplo n.º 9
0
def test_shouldGetDependencies():
    root = Goal(Decomposition.AND)

    task = Task("T1")
    goal = Goal(Decomposition.AND, "G1")
    delegation = Delegation("D1")

    root.addDependency(task)
    root.addDependency(goal)
    root.addDependency(delegation)

    deps = []
    deps.append(delegation)
    deps.append(goal)
    deps.append(task)

    for d in deps:
        assert d in root.dependencies
Exemplo n.º 10
0
def test_shouldGetApplicableDependencies():
    root = Goal(Decomposition.AND)

    context = Context("c1")
    current = []
    current.append(context)

    task = Task()
    goal = Goal(Decomposition.AND)
    delegation = Delegation()

    task.addApplicableContext(context)

    root.addDependency(task)
    root.addDependency(goal)
    root.addDependency(delegation)

    deps = []
    deps.append(task)

    assert 1 == len(deps)
    assert task in deps
Exemplo n.º 11
0
    def __init__(self, decomposition, identifier=""):
        Goal.__init__(self, decomposition, identifier)

        self.interp = Interpretation()
Exemplo n.º 12
0
def rootGoal():

    # Goals
    respondToEmergencyGoal = Pragmatic(Decomposition.AND, "respondToEmergency")
    emergencyIsDetectedGoal = Pragmatic(Decomposition.OR,
                                        "emergencyIsDetected")
    centralReceivesInfoGoal = Pragmatic(Decomposition.AND,
                                        "centralReceivesInfo")
    locationIsIdentifiedGoal = Pragmatic(Decomposition.OR,
                                         "locationIsIdentified")
    infoIsPreparedGoal = Pragmatic(Decomposition.OR, "infoIsPrepared")
    isNotifiedAboutEmergencyGoal = Pragmatic(Decomposition.OR,
                                             "isNotifiedAboutEmergency")
    callForHelpIsAcceptedGoal = Goal(Decomposition.AND,
                                     "callForHelpIsAccepted")
    falseAlarmIsCheckedGoal = Goal(Decomposition.OR, "falseAlarmIsChecked")
    pIsContactedGoal = Goal(Decomposition.AND, "pIsContacted")
    receivesEmergencyButtonCallGoal = Goal(Decomposition.OR,
                                           "receivesEmergencyButtonCall")
    situationsAreIdentifiedGoal = Goal(Decomposition.AND,
                                       "situationsAreIdentified")
    vitalSignsAreMonitoredGoal = Goal(Decomposition.AND,
                                      "vitalSignsAreMonitored")
    infoIsSentToEmergencyGoal = Goal(Decomposition.OR, "infoIsSentToEmergency")
    setupAutomatedInfoGoal = Goal(Decomposition.AND, "setupAutomatedInfo")
    situationDataIsRecoveredGoal = Goal(Decomposition.AND,
                                        "situationDataIsRecovered")
    contactResponsibleGoal = Goal(Decomposition.AND, "contactResponsible")
    medicalCareReachesGoal = Goal(Decomposition.AND, "medicalCareReaches")
    ambulanceIsDispatchedToLocationGoal = Goal(
        Decomposition.AND, "ambulanceIsDispatchedToLocation")

    # Refinements
    respondToEmergencyGoal.addDependency(emergencyIsDetectedGoal)
    respondToEmergencyGoal.addDependency(isNotifiedAboutEmergencyGoal)
    respondToEmergencyGoal.addDependency(centralReceivesInfoGoal)
    respondToEmergencyGoal.addDependency(medicalCareReachesGoal)

    emergencyIsDetectedGoal.addDependency(callForHelpIsAcceptedGoal)
    emergencyIsDetectedGoal.addDependency(situationsAreIdentifiedGoal)

    callForHelpIsAcceptedGoal.addDependency(receivesEmergencyButtonCallGoal)
    callForHelpIsAcceptedGoal.addDependency(falseAlarmIsCheckedGoal)

    receivesEmergencyButtonCallGoal.addDependency(notifyCentralBySMSTask)
    receivesEmergencyButtonCallGoal.addDependency(notifyCentralByInternetTask)

    falseAlarmIsCheckedGoal.addDependency(acceptEmergencyTask)
    falseAlarmIsCheckedGoal.addDependency(pIsContactedGoal)

    pIsContactedGoal.addDependency(confirmEmergencyByCallTask)

    situationsAreIdentifiedGoal.addDependency(processDataFromSensorsTask)
    situationsAreIdentifiedGoal.addDependency(vitalSignsAreMonitoredGoal)
    situationsAreIdentifiedGoal.addDependency(identifySituationTask)

    vitalSignsAreMonitoredGoal.addDependency(collectDataFromSensorsTask)
    vitalSignsAreMonitoredGoal.addDependency(persistDataToDatabaseTask)

    isNotifiedAboutEmergencyGoal.addDependency(notifyByMobileVibrationTask)
    isNotifiedAboutEmergencyGoal.addDependency(notifyBySoundAlertTask)
    isNotifiedAboutEmergencyGoal.addDependency(notifyByLightAlertTask)
    isNotifiedAboutEmergencyGoal.addDependency(centralCallTask)

    centralReceivesInfoGoal.addDependency(infoIsSentToEmergencyGoal)
    centralReceivesInfoGoal.addDependency(infoIsPreparedGoal)

    infoIsSentToEmergencyGoal.addDependency(sendInfoBySMSTask)
    infoIsSentToEmergencyGoal.addDependency(sendInfoByInternetTask)

    infoIsPreparedGoal.addDependency(setupAutomatedInfoGoal)
    infoIsPreparedGoal.addDependency(contactResponsibleGoal)

    setupAutomatedInfoGoal.addDependency(locationIsIdentifiedGoal)
    setupAutomatedInfoGoal.addDependency(situationDataIsRecoveredGoal)

    locationIsIdentifiedGoal.addDependency(considerLastKnownLocationTask)
    locationIsIdentifiedGoal.addDependency(identifyLocationByVoiceCallTask)
    locationIsIdentifiedGoal.addDependency(accessLocationFromGPSTask)
    locationIsIdentifiedGoal.addDependency(accessLocationFromTriangulationTask)

    situationDataIsRecoveredGoal.addDependency(accessDataFromDatabaseTask)

    contactResponsibleGoal.addDependency(getInfoFromResponsibleTask)

    medicalCareReachesGoal.addDependency(ambulanceIsDispatchedToLocationGoal)

    ambulanceIsDispatchedToLocationGoal.addDependency(
        ambulanceDispatchDelegationTask)

    # Applicable Contexts

    notifyCentralBySMSTask.addApplicableContext(c2)

    notifyCentralByInternetTask.addApplicableContext(c3)
    notifyCentralByInternetTask.addApplicableContext(c4)

    acceptEmergencyTask.addNonapplicableContext(c2)

    confirmEmergencyByCallTask.addApplicableContext(c2)

    notifyByMobileVibrationTask.addApplicableContext(c1)

    notifyBySoundAlertTask.addApplicableContext(c6)

    notifyByLightAlertTask.addApplicableContext(c7)

    centralCallTask.addApplicableContext(c8)

    sendInfoBySMSTask.addApplicableContext(c2)

    sendInfoByInternetTask.addApplicableContext(c3)
    sendInfoByInternetTask.addApplicableContext(c4)

    identifyLocationByVoiceCallTask.addApplicableContext(c2)

    accessLocationFromTriangulationTask.addApplicableContext(c2)

    accessLocationFromGPSTask.addApplicableContext(c5)

    # Goal Interpretations

    qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 180,
                            Comparison.LESS_THAN)
    qc2 = QualityConstraint(c10, MpersMetrics.SECONDS, 90,
                            Comparison.LESS_THAN)
    qc3 = QualityConstraint(c9, MpersMetrics.SECONDS, 240,
                            Comparison.LESS_THAN)
    respondToEmergencyGoal.interp.addQualityConstraint(qc1)
    respondToEmergencyGoal.interp.addQualityConstraint(qc2)
    respondToEmergencyGoal.interp.addQualityConstraint(qc3)

    qc1 = QualityConstraint(None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 30,
                            Comparison.LESS_THAN)
    qc2 = QualityConstraint(c3, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 10,
                            Comparison.LESS_THAN)
    qc3 = QualityConstraint(c9, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5,
                            Comparison.LESS_THAN)
    emergencyIsDetectedGoal.interp.addQualityConstraint(qc1)
    emergencyIsDetectedGoal.interp.addQualityConstraint(qc2)
    emergencyIsDetectedGoal.interp.addQualityConstraint(qc3)

    qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 60,
                            Comparison.LESS_THAN)
    centralReceivesInfoGoal.interp.addQualityConstraint(qc1)

    qc4 = QualityConstraint(None, MpersMetrics.DISTANCE_ERROR, 1000,
                            Comparison.LESS_THAN)
    qc6 = QualityConstraint(c5, MpersMetrics.DISTANCE_ERROR, 20,
                            Comparison.LESS_THAN)
    qc5 = QualityConstraint(c10, MpersMetrics.DISTANCE_ERROR, 200,
                            Comparison.LESS_THAN)
    qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 120,
                            Comparison.LESS_THAN)
    qc3 = QualityConstraint(c9, MpersMetrics.SECONDS, 240,
                            Comparison.LESS_THAN)
    qc2 = QualityConstraint(c10, MpersMetrics.SECONDS, 20,
                            Comparison.LESS_THAN)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc1)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc2)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc3)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc4)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc5)
    locationIsIdentifiedGoal.interp.addQualityConstraint(qc6)

    qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 900,
                            Comparison.LESS_THAN)
    qc2 = QualityConstraint(c10, MpersMetrics.SECONDS, 600,
                            Comparison.LESS_THAN)
    infoIsPreparedGoal.interp.addQualityConstraint(qc1)
    infoIsPreparedGoal.interp.addQualityConstraint(qc2)

    qc1 = QualityConstraint(None, MpersMetrics.NOISE, 10, Comparison.LESS_THAN)
    qc2 = QualityConstraint(c1, MpersMetrics.NOISE, 3, Comparison.LESS_THAN)
    isNotifiedAboutEmergencyGoal.interp.addQualityConstraint(qc1)
    isNotifiedAboutEmergencyGoal.interp.addQualityConstraint(qc2)

    # Provided Task QoS

    notifyCentralBySMSTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 10)

    notifyCentralByInternetTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5)

    acceptEmergencyTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 30)

    confirmEmergencyByCallTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5)

    processDataFromSensorsTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 15)

    collectDataFromSensorsTask.setProvidedQuality(None, MpersMetrics.SECONDS,
                                                  120)
    collectDataFromSensorsTask.setProvidedQuality(c3, MpersMetrics.SECONDS, 60)

    persistDataToDatabaseTask.setProvidedQuality(None, MpersMetrics.SECONDS, 5)

    identifySituationTask.setProvidedQuality(
        None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 20)

    notifyByMobileVibrationTask.setProvidedQuality(None, MpersMetrics.NOISE, 2)
    notifyBySoundAlertTask.setProvidedQuality(None, MpersMetrics.NOISE, 9)
    notifyByLightAlertTask.setProvidedQuality(None, MpersMetrics.NOISE, 0)
    centralCallTask.setProvidedQuality(None, MpersMetrics.NOISE, 7)

    sendInfoBySMSTask.setProvidedQuality(None, MpersMetrics.SECONDS, 65)
    sendInfoBySMSTask.setProvidedQuality(c8, MpersMetrics.SECONDS, 45)

    sendInfoByInternetTask.setProvidedQuality(None, MpersMetrics.SECONDS, 40)

    considerLastKnownLocationTask.setProvidedQuality(
        None, MpersMetrics.DISTANCE_ERROR, 900)
    considerLastKnownLocationTask.setProvidedQuality(None,
                                                     MpersMetrics.SECONDS, 15)

    identifyLocationByVoiceCallTask.setProvidedQuality(
        None, MpersMetrics.DISTANCE_ERROR, 100)
    identifyLocationByVoiceCallTask.setProvidedQuality(
        c11, MpersMetrics.DISTANCE_ERROR, 300)
    identifyLocationByVoiceCallTask.setProvidedQuality(None,
                                                       MpersMetrics.SECONDS,
                                                       45)

    accessLocationFromTriangulationTask.setProvidedQuality(
        None, MpersMetrics.DISTANCE_ERROR, 40)
    accessLocationFromTriangulationTask.setProvidedQuality(
        c11, MpersMetrics.DISTANCE_ERROR, 400)
    accessLocationFromTriangulationTask.setProvidedQuality(
        None, MpersMetrics.SECONDS, 30)

    accessLocationFromGPSTask.setProvidedQuality(None,
                                                 MpersMetrics.DISTANCE_ERROR,
                                                 20)
    accessLocationFromGPSTask.setProvidedQuality(c11,
                                                 MpersMetrics.DISTANCE_ERROR,
                                                 30)
    accessLocationFromGPSTask.setProvidedQuality(None, MpersMetrics.SECONDS,
                                                 50)

    accessDataFromDatabaseTask.setProvidedQuality(None, MpersMetrics.SECONDS,
                                                  20)

    getInfoFromResponsibleTask.setProvidedQuality(None, MpersMetrics.SECONDS,
                                                  25)
    getInfoFromResponsibleTask.setProvidedQuality(c11, MpersMetrics.SECONDS,
                                                  50)

    ambulanceDispatchDelegationTask.setProvidedQuality(None,
                                                       MpersMetrics.SECONDS,
                                                       30)

    rootGoal = Goal(Decomposition.AND, "rootGoal")
    rootGoal = respondToEmergencyGoal

    return rootGoal
Exemplo n.º 13
0
 def __init__(self):
     # Goals
     self.respondToEmergencyGoal = Pragmatic(Decomposition.AND,
                                             "respondToEmergencyGoal")
     self.emergencyIsDetectedGoal = Pragmatic(Decomposition.OR,
                                              "emergencyIsDetectedGoal")
     self.centralReceivesInfoGoal = Pragmatic(Decomposition.AND,
                                              "centralReceivesInfoGoal")
     self.locationIsIdentifiedGoal = Pragmatic(Decomposition.OR,
                                               "locationIsIdentifiedGoal")
     self.infoIsPreparedGoal = Pragmatic(Decomposition.OR,
                                         "infoIsPreparedGoal")
     self.isNotifiedAboutEmergencyGoal = Pragmatic(
         Decomposition.OR, "isNotifiedAboutEmergencyGoal")
     self.callForHelpIsAcceptedGoal = Goal(Decomposition.AND,
                                           "callForHelpIsAcceptedGoal")
     self.falseAlarmIsCheckedGoal = Goal(Decomposition.OR,
                                         "falseAlarmIsCheckedGoal")
     self.pIsContacted = Goal(Decomposition.AND, "pIsContacted")
     self.receivesEmergencyButtonCallGoal = Goal(
         Decomposition.OR, "receivesEmergencyButtonCallGoal")
     self.situationsAreIdentifiedGoal = Goal(Decomposition.AND,
                                             "situationsAreIdentifiedGoal")
     self.vitalSignsAreMonitoredGoal = Goal(Decomposition.AND,
                                            "vitalSignsAreMonitoredGoal")
     self.infoIsSentToEmergencyGoal = Goal(Decomposition.OR,
                                           "infoIsSentToEmergencyGoal")
     self.setupAutomatedInfoGoal = Goal(Decomposition.AND,
                                        "setupAutomatedInfoGoal")
     self.situationDataIsRecoveredGoal = Goal(
         Decomposition.AND, "situationDataIsRecoveredGoal")
     self.contactResponsibleGoal = Goal(Decomposition.AND,
                                        "contactResponsibleGoal")
     self.medicalCareReachesGoal = Goal(Decomposition.AND,
                                        "medicalCareReachesGoal")
     self.ambulanceIsDispatchedToLocationGoal = Goal(
         Decomposition.AND, "ambulanceIsDispatchedToLocationGoal")
Exemplo n.º 14
0
    def __init__(self):

        self.tasks = MpersTasks()
        self.goals = MpersGoals()

        # Refinements

        self.goals.respondToEmergencyGoal.addDependency(
            self.goals.emergencyIsDetectedGoal)
        self.goals.respondToEmergencyGoal.addDependency(
            self.goals.isNotifiedAboutEmergencyGoal)
        self.goals.respondToEmergencyGoal.addDependency(
            self.goals.centralReceivesInfoGoal)
        self.goals.respondToEmergencyGoal.addDependency(
            self.goals.medicalCareReachesGoal)

        self.goals.emergencyIsDetectedGoal.addDependency(
            self.goals.callForHelpIsAcceptedGoal)
        self.goals.emergencyIsDetectedGoal.addDependency(
            self.goals.situationsAreIdentifiedGoal)

        self.goals.callForHelpIsAcceptedGoal.addDependency(
            self.goals.receivesEmergencyButtonCallGoal)
        self.goals.callForHelpIsAcceptedGoal.addDependency(
            self.goals.falseAlarmIsCheckedGoal)

        self.goals.receivesEmergencyButtonCallGoal.addDependency(
            self.tasks.notifyCentralBySMSTask)
        self.goals.receivesEmergencyButtonCallGoal.addDependency(
            self.tasks.notifyCentralByInternetTask)

        self.goals.falseAlarmIsCheckedGoal.addDependency(
            self.tasks.acceptEmergencyTask)
        self.goals.falseAlarmIsCheckedGoal.addDependency(
            self.goals.pIsContacted)

        self.goals.pIsContacted.addDependency(
            self.tasks.confirmEmergencyByCallTask)

        self.goals.situationsAreIdentifiedGoal.addDependency(
            self.tasks.processDataFromSensorsTask)
        self.goals.situationsAreIdentifiedGoal.addDependency(
            self.goals.vitalSignsAreMonitoredGoal)
        self.goals.situationsAreIdentifiedGoal.addDependency(
            self.tasks.identifySituationTask)

        self.goals.vitalSignsAreMonitoredGoal.addDependency(
            self.tasks.collectDataFromSensorsTask)
        self.goals.vitalSignsAreMonitoredGoal.addDependency(
            self.tasks.persistDataToDatabaseTask)

        self.goals.isNotifiedAboutEmergencyGoal.addDependency(
            self.tasks.notifyByLightAlertTask)
        self.goals.isNotifiedAboutEmergencyGoal.addDependency(
            self.tasks.notifyByMobileVibrationTask)
        self.goals.isNotifiedAboutEmergencyGoal.addDependency(
            self.tasks.notifyBySoundAlertTask)
        self.goals.isNotifiedAboutEmergencyGoal.addDependency(
            self.tasks.centralCallTask)

        self.goals.centralReceivesInfoGoal.addDependency(
            self.goals.infoIsSentToEmergencyGoal)
        self.goals.centralReceivesInfoGoal.addDependency(
            self.goals.infoIsPreparedGoal)

        self.goals.infoIsSentToEmergencyGoal.addDependency(
            self.tasks.sendInfoBySMSTask)
        self.goals.infoIsSentToEmergencyGoal.addDependency(
            self.tasks.sendInfoByInternetTask)

        self.goals.infoIsPreparedGoal.addDependency(
            self.goals.setupAutomatedInfoGoal)
        self.goals.infoIsPreparedGoal.addDependency(
            self.goals.contactResponsibleGoal)

        self.goals.setupAutomatedInfoGoal.addDependency(
            self.goals.locationIsIdentifiedGoal)
        self.goals.setupAutomatedInfoGoal.addDependency(
            self.goals.situationDataIsRecoveredGoal)

        self.goals.locationIsIdentifiedGoal.addDependency(
            self.tasks.accessLocationFromTriangulationTask)
        self.goals.locationIsIdentifiedGoal.addDependency(
            self.tasks.considerLastKnownLocationTask)
        self.goals.locationIsIdentifiedGoal.addDependency(
            self.tasks.identifyLocationByVoiceCallTask)
        self.goals.locationIsIdentifiedGoal.addDependency(
            self.tasks.accessLocationFromGPSTask)

        self.goals.situationDataIsRecoveredGoal.addDependency(
            self.tasks.accessDataFromDatabaseTask)

        self.goals.contactResponsibleGoal.addDependency(
            self.tasks.getInfoFromResponsibleTask)

        self.goals.medicalCareReachesGoal.addDependency(
            self.goals.ambulanceIsDispatchedToLocationGoal)

        self.goals.ambulanceIsDispatchedToLocationGoal.addDependency(
            self.tasks.ambulanceDispatchDelegationTask)

        # Applicable Contexts

        self.tasks.notifyCentralBySMSTask.addApplicableContext(
            self.contexts.c2)

        self.tasks.notifyCentralByInternetTask.addApplicableContext(
            self.contexts.c3)
        self.tasks.notifyCentralByInternetTask.addApplicableContext(
            self.contexts.c4)

        self.tasks.acceptEmergencyTask.addNonapplicableContext(
            self.contexts.c2)

        self.tasks.confirmEmergencyByCallTask.addApplicableContext(
            self.contexts.c2)

        self.tasks.notifyByMobileVibrationTask.addApplicableContext(
            self.contexts.c1)

        self.tasks.notifyBySoundAlertTask.addApplicableContext(
            self.contexts.c6)

        self.tasks.notifyByLightAlertTask.addApplicableContext(
            self.contexts.c7)

        self.tasks.centralCallTask.addApplicableContext(self.contexts.c8)

        self.tasks.sendInfoBySMSTask.addApplicableContext(self.contexts.c2)

        self.tasks.sendInfoByInternetTask.addApplicableContext(
            self.contexts.c3)
        self.tasks.sendInfoByInternetTask.addApplicableContext(
            self.contexts.c4)

        self.tasks.identifyLocationByVoiceCallTask.addApplicableContext(
            self.contexts.c2)

        self.tasks.accessLocationFromTriangulationTask.addApplicableContext(
            self.contexts.c2)

        self.tasks.accessLocationFromGPSTask.addApplicableContext(
            self.contexts.c5)

        # Goal Interpretation

        qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 180,
                                Comparison.LESS_OR_EQUAL_TO)
        qc2 = QualityConstraint(self.contexts.c10, MpersMetrics.SECONDS, 90,
                                Comparison.LESS_OR_EQUAL_TO)
        qc3 = QualityConstraint(self.contexts.c9, MpersMetrics.SECONDS, 240,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.respondToEmergencyGoal.interp.addQualityConstraint(qc1)
        self.goals.respondToEmergencyGoal.interp.addQualityConstraint(qc2)
        self.goals.respondToEmergencyGoal.interp.addQualityConstraint(qc3)

        qc1 = QualityConstraint(None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE,
                                30, Comparison.LESS_OR_EQUAL_TO)
        qc2 = QualityConstraint(self.contexts.c3,
                                MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 10,
                                Comparison.LESS_OR_EQUAL_TO)
        qc3 = QualityConstraint(self.contexts.c9,
                                MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.emergencyIsDetectedGoal.interp.addQualityConstraint(qc1)
        self.goals.emergencyIsDetectedGoal.interp.addQualityConstraint(qc2)
        self.goals.emergencyIsDetectedGoal.interp.addQualityConstraint(qc3)

        qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 60,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.centralReceivesInfoGoal.interp.addQualityConstraint(qc1)

        qc4 = QualityConstraint(None, MpersMetrics.DISTANCE_ERROR, 1000,
                                Comparison.LESS_OR_EQUAL_TO)
        qc6 = QualityConstraint(self.contexts.c5, MpersMetrics.DISTANCE_ERROR,
                                20, Comparison.LESS_OR_EQUAL_TO)
        qc5 = QualityConstraint(self.contexts.c10, MpersMetrics.DISTANCE_ERROR,
                                200, Comparison.LESS_OR_EQUAL_TO)
        qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 120,
                                Comparison.LESS_OR_EQUAL_TO)
        qc3 = QualityConstraint(self.contexts.c9, MpersMetrics.SECONDS, 240,
                                Comparison.LESS_OR_EQUAL_TO)
        qc2 = QualityConstraint(self.contexts.c10, MpersMetrics.SECONDS, 20,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc1)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc2)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc3)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc4)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc5)
        self.goals.locationIsIdentifiedGoal.interp.addQualityConstraint(qc6)

        qc1 = QualityConstraint(None, MpersMetrics.SECONDS, 45,
                                Comparison.LESS_OR_EQUAL_TO)
        qc2 = QualityConstraint(self.contexts.c10, MpersMetrics.SECONDS, 30,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.infoIsPreparedGoal.interp.addQualityConstraint(qc1)
        self.goals.infoIsPreparedGoal.interp.addQualityConstraint(qc2)

        qc1 = QualityConstraint(None, MpersMetrics.NOISE, 10,
                                Comparison.LESS_OR_EQUAL_TO)
        qc2 = QualityConstraint(self.contexts.c1, MpersMetrics.NOISE, 3,
                                Comparison.LESS_OR_EQUAL_TO)
        self.goals.isNotifiedAboutEmergencyGoal.interp.addQualityConstraint(
            qc1)
        self.goals.isNotifiedAboutEmergencyGoal.interp.addQualityConstraint(
            qc2)

        # Provided Task QoS
        self.tasks.notifyCentralBySMSTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 10)

        self.tasks.notifyCentralByInternetTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5)

        self.tasks.acceptEmergencyTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 30)

        self.tasks.confirmEmergencyByCallTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 5)

        self.tasks.processDataFromSensorsTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 15)

        self.tasks.collectDataFromSensorsTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 120)
        self.tasks.collectDataFromSensorsTask.setProvidedQuality(
            self.contexts.c3, MpersMetrics.SECONDS, 60)

        self.tasks.persistDataToDatabaseTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 5)

        self.tasks.identifySituationTask.setProvidedQuality(
            None, MpersMetrics.FALSE_NEGATIVE_PERCENTAGE, 20)

        self.tasks.notifyByMobileVibrationTask.setProvidedQuality(
            None, MpersMetrics.NOISE, 2)
        self.tasks.notifyBySoundAlertTask.setProvidedQuality(
            None, MpersMetrics.NOISE, 9)
        self.tasks.notifyByLightAlertTask.setProvidedQuality(
            None, MpersMetrics.NOISE, 0)
        self.tasks.centralCallTask.setProvidedQuality(None, MpersMetrics.NOISE,
                                                      7)

        self.tasks.sendInfoBySMSTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 65)
        self.tasks.sendInfoBySMSTask.setProvidedQuality(
            self.contexts.c8, MpersMetrics.SECONDS, 45)

        self.tasks.sendInfoByInternetTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 40)

        self.tasks.considerLastKnownLocationTask.setProvidedQuality(
            None, MpersMetrics.DISTANCE_ERROR, 900)
        self.tasks.considerLastKnownLocationTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 15)

        self.tasks.identifyLocationByVoiceCallTask.setProvidedQuality(
            None, MpersMetrics.DISTANCE_ERROR, 100)
        self.tasks.identifyLocationByVoiceCallTask.setProvidedQuality(
            self.contexts.c11, MpersMetrics.DISTANCE_ERROR, 300)
        self.tasks.identifyLocationByVoiceCallTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 45)

        self.tasks.accessLocationFromTriangulationTask.setProvidedQuality(
            None, MpersMetrics.DISTANCE_ERROR, 40)
        self.tasks.accessLocationFromTriangulationTask.setProvidedQuality(
            self.contexts.c11, MpersMetrics.DISTANCE_ERROR, 400)
        self.tasks.accessLocationFromTriangulationTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 30)

        self.tasks.accessLocationFromGPSTask.setProvidedQuality(
            None, MpersMetrics.DISTANCE_ERROR, 20)
        self.tasks.accessLocationFromGPSTask.setProvidedQuality(
            self.contexts.c11, MpersMetrics.DISTANCE_ERROR, 30)
        self.tasks.accessLocationFromGPSTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 50)

        self.tasks.accessDataFromDatabaseTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 20)

        self.tasks.getInfoFromResponsibleTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 25)
        self.tasks.getInfoFromResponsibleTask.setProvidedQuality(
            self.contexts.c11, MpersMetrics.SECONDS, 50)

        self.tasks.ambulanceDispatchDelegationTask.setProvidedQuality(
            None, MpersMetrics.SECONDS, 30)

        self.rootGoal = Goal(Decomposition.AND, "rootGoal")
        self.rootGoal = self.goals.respondToEmergencyGoal