예제 #1
0
def priority_goals():
    """Parse Goals from Structured Text File"""

    goals = parse('../input_files/priority_goals.txt')
    """Declare New Goals that are built on top of existing goals"""

    keep_short_distance = conjoin_goals(
        [goals["accelerate_follow"], goals["decelerate_distance"]],
        name="keep_short_distance",
        description="keep a short distance from the vehicle ahead")
예제 #2
0
파일: example.py 프로젝트: pierg/cogomo
def platooning_example():
    """Parse Goals from Structured Text File"""

    curpath = os.path.dirname(os.path.realpath(__file__))

    goals = parse(os.path.join(curpath, 'input_files/example_platooning.txt'))

    keep_short_distance = conjoin_goals(
        [
            goals["accelerate_distance"], goals["decelerate_distance"],
            goals["maintainspeed_distance"]
        ],
        name="keep_short_distance",
        description="keep a short distance from the vehicle ahead")

    follow_leader = conjoin_goals(
        [
            goals["accelerate_follow"], goals["decelerate_follow"],
            goals["maintainspeed_follow"]
        ],
        name="follow_leader",
        description="follow the leader vehicle by keeping its speed")

    prioritize_goal(keep_short_distance, follow_leader)

    speed_control = conjoin_goals(
        [keep_short_distance, follow_leader],
        name="speed_control",
        description=
        "control the speed of the vehicle based either on the distance to the vehicle in front "
        "or according the the leader of the platoon")

    communicate_with_platoon_leader_refined = compose_goals(
        [goals['enstablish_connection_fixed'], goals['retrieve_information']],
        "communicate_with_platoon_leader_refined")

    refine_goal(goals['communicate_with_platoon_leader'],
                communicate_with_platoon_leader_refined)

    following_communication = compose_goals(
        [speed_control, goals['communicate_with_platoon_leader']],
        name="following_communication",
        description="followin mode of the platoon")

    goals["keep_short_distance"] = keep_short_distance
    goals["follow_leader"] = follow_leader
    goals["speed_control"] = speed_control
    goals[
        "communicate_with_platoon_leader_refined"] = communicate_with_platoon_leader_refined
    goals["following_communication"] = following_communication

    print(str(following_communication.n_children()) + " NODES TOTAL")

    return goals, following_communication
예제 #3
0
def case2():
    goals = parse('../input_files/test_completeness.txt')

    try:
        refine_goal(goals['communicate_with_platoon_leader_abstracted'],
                    goals['communicate_with_platoon_leader_refined'])
    except Exception:
        print("Refinement not complete, Fixing..")

        refine_goal(
            goals['communicate_with_platoon_leader_abstracted_complete'],
            goals['communicate_with_platoon_leader_refined_complete'])

        print(goals['communicate_with_platoon_leader_abstracted_complete'])
        print(goals['communicate_with_platoon_leader_refined_complete'])
예제 #4
0
def composition_example():
    """Parse Goals from Structured Text File"""

    goals = parse('../input_files/composable_goals.txt')

    composed_goals = compose_goals(
        [goals["component_A"], goals["component_C"]],
        name="composedAB",
        description="composed components A and B")

    composed_goals = compose_goals(
        [goals["component_A"], goals["component_C"]],
        name="composedAB",
        description="composed components A and B")

    print(composed_goals)
예제 #5
0
def conjoing_and_prioritise_goals():
    """Parse Goals from Structured Text File"""

    goals = parse('../input_files/platooning.txt')
    """Declare New Goals that are built on top of existing goals"""
    keep_short_distance = None
    follow_leader = None
    following = None

    try:
        keep_short_distance = conjoin_goals(
            [
                goals["accelerate_distance"], goals["decelerate_distance"],
                goals["maintainspeed_distance"]
            ],
            name="keep_short_distance",
            description="keep a short distance from the vehicle ahead")

        follow_leader = conjoin_goals(
            [
                goals["accelerate_follow"], goals["decelerate_follow"],
                goals["maintainspeed_follow"]
            ],
            name="follow_leader",
            description="follow the leader vehicle by keeping its speed")

        following_mode = conjoin_goals(
            [keep_short_distance, follow_leader],
            name="following_mode",
            description="following mode of the platooning")

    except Exception:
        """Let's prioritize 'keep_short_distance' over 'follow_leader' """

        print("\nPrioritizing goals...")
        prioritize_goal(keep_short_distance, follow_leader)

        print("\nTrying to conjoin again...")
        following = conjoin_goals(
            [keep_short_distance, follow_leader],
            name="following",
            description="following the car in front and the leader")

    following_mode = compose_goals([following, goals["communication_leader"]],
                                   name="following_communication",
                                   description="followin mode")
예제 #6
0
#!/usr/bin/env python
"""Test Library module provides a test suite for LTL contract verifier"""

import os
import sys

from src_z3.parser import parse
from src_z3.cgtgoal import *

from src_z3.operations import *

sys.path.append(os.path.join(os.getcwd(), os.path.pardir))



if __name__ == "__main__":

    goals = parse('../input_files/empty_assumptions.txt')

    composition = compose_goals([goals["goal_1"], goals["goal_2"]], name="composition")

    print(composition)

예제 #7
0
"""Test Library module provides a test suite for LTL contract verifier"""

import os
import sys

from src_z3.parser import parse
from src_z3.cgtgoal import *

from src_z3.operations import *

sys.path.append(os.path.join(os.getcwd(), os.path.pardir))

if __name__ == "__main__":
    """Parse Goals from Structured Text File"""

    goals = parse('./input_files/platooning.txt')

    """Declare New Goals that are built on top of existing goals"""
    keep_short_distance = None
    follow_leader = None
    speed_control = None

    try:
        keep_short_distance = conjoin_goals(
            [goals["accelerate_distance"], goals["decelerate_distance"], goals["maintainspeed_distance"]],
            name="keep_short_distance",
            description="keep a short distance from the vehicle ahead")

        follow_leader = conjoin_goals(
            [goals["accelerate_follow"], goals["decelerate_follow"], goals["maintainspeed_follow"]],
            name="follow_leader",
예제 #8
0
#!/usr/bin/env python
"""Test Library module provides a test suite for LTL contract verifier"""

import os
import sys

from src_z3.parser import parse
from src_z3.cgtgoal import *

from src_z3.operations import *

sys.path.append(os.path.join(os.getcwd(), os.path.pardir))

if __name__ == "__main__":

    goals = parse('../input_files/incorrect_refinement.txt')

    refine_goal(goals["abstraction"], goals["refinement_a"])
예제 #9
0
        refine_goal(goals['communicate_with_platoon_leader_abstracted'],
                    goals['communicate_with_platoon_leader_refined'])
    except Exception:
        print("Refinement not complete, Fixing..")

        refine_goal(
            goals['communicate_with_platoon_leader_abstracted_complete'],
            goals['communicate_with_platoon_leader_refined_complete'])

        print(goals['communicate_with_platoon_leader_abstracted_complete'])
        print(goals['communicate_with_platoon_leader_refined_complete'])


if __name__ == "__main__":

    goals = parse('../input_files/decomposition.txt')

    communicate_with_platoon_leader_refined = compose_goals(
        [goals['enstablish_connection'], goals['retrieve_information']],
        "communicate_with_platoon_leader_refined")

    try:

        refine_goal(goals['communicate_with_platoon_leader'],
                    communicate_with_platoon_leader_refined)

        print(goals['communicate_with_platoon_leader'])

    except Exception:
        print("Exception occurred")
        print("Fixing the assumptions..")