Commit f25adee3 by Jaeyoung Lee

Refactoring (change the module name "model_checker" to "verifier")

parent f443e382
from model_checker import Parser
from verifier import Parser
class GymCompliantEnvBase:
......
......@@ -10,7 +10,7 @@ from .utilities import BoundingBox as bb_utils
from .features import Features
from .constants import *
from model_checker.simple_intersection import LTLProperty
from verifier.simple_intersection import LTLProperty
# import the classes for graphical output.
from .shapes import Text, Image
......
from . import road_geokinemetry as rd
import numpy as np
from model_checker.simple_intersection import AtomicPropositions
from verifier.simple_intersection import AtomicPropositions
from .utilities import BoundingBox as bb_utils
from .constants import *
......
......@@ -2,12 +2,19 @@ from .maneuver_base import ManeuverBase
from env.simple_intersection.constants import *
import env.simple_intersection.road_geokinemetry as rd
from env.simple_intersection.features import extract_ego_features, extract_other_veh_features
from model_checker.simple_intersection import LTLProperty
from verifier.simple_intersection import LTLProperty
import numpy as np
# TODO: separate out into different files?? is it really needed?
"""
enable_additional_properties=
True means the maneuver uses the additional properties,
False means not.
"""
enable_additional_properties = False
class KeepLane(ManeuverBase):
def _init_param(self):
......@@ -35,7 +42,8 @@ class KeepLane(ManeuverBase):
# the goal reward and termination is led by the SimpleIntersectionEnv
self.env._terminate_in_goal = False
self.env._reward_in_goal = None
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = True
def generate_validation_scenario(self):
......@@ -45,8 +53,9 @@ class KeepLane(ManeuverBase):
ego_perturb_lim=(rd.hlanes.width / 4, np.pi / 6),
ego_heading_towards_lane_centre=True)
# the goal reward and termination is led by the SimpleIntersectionEnv
self.env._terminate_in_goal = False
self.env._reward_in_goal = None
self.env._terminate_in_goal = True
self.env._reward_in_goal = 200
self._enable_low_level_training_properties = False
@staticmethod
def _features_dim_reduction(features_tuple):
......@@ -91,7 +100,8 @@ class Halt(ManeuverBase):
self._target_lane = self.env.ego.APs['lane']
def _init_LTL_preconditions(self):
# TODO: give another variable in ManeuverBase that enables high-level-only properties
# (currently, this functionality is implemented by "not self._enable_low_level_training_properties")
self._LTL_preconditions.append(
LTLProperty(
"G ( (veh_ahead and before_but_close_to_stop_region) U highest_priority )",
......@@ -114,11 +124,14 @@ class Halt(ManeuverBase):
self.env._terminate_in_goal = False
self.env._reward_in_goal = None
self._reward_in_goal = 200
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = True
def generate_validation_scenario(self):
self._ego_pos_range = (rd.hlanes.start_pos, rd.hlanes.end_pos)
# TODO: Separate out the high-level-only properties and add a code
# "self._enable_low_level_training_properties = False" (just like the other maneuvers).
self.generate_learning_scenario()
def _low_level_manual_policy(self):
......@@ -201,7 +214,8 @@ class Stop(ManeuverBase):
ego_heading_towards_lane_centre=True)
self._reward_in_goal = 200
self._penalty_in_violation = 150
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = True
def _low_level_manual_policy(self):
......@@ -302,7 +316,8 @@ class Wait(ManeuverBase):
self.env.init_APs(False)
self.env._terminate_in_goal = False
self._reward_in_goal = 200
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = False
@property
......@@ -452,20 +467,21 @@ class ChangeLane(ManeuverBase):
# print('our range was %s, %s, ego at %s' % (before_intersection, after_intersection, self.env.ego.x))
self._reward_in_goal = 200
self._violation_penalty_in_low_level_training = 150
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = True
self.env._terminate_in_goal = False
def generate_validation_scenario(self):
self.generate_scenario(
enable_LTL_preconditions=False,
ego_pos_range=(rd.hlanes.start_pos, rd.hlanes.end_pos),
ego_pos_range=(rd.intersection_width_w_offset, rd.hlanes.end_pos),
ego_perturb_lim=(rd.hlanes.width / 4, np.pi / 6))
# print('our range was %s, %s, ego at %s' % (before_intersection, after_intersection, self.env.ego.x))
self._reward_in_goal = 200
self._violation_penalty_in_low_level_training = 150
self._enable_low_level_training_properties = True
self._enable_low_level_training_properties = False
self.env._terminate_in_goal = False
......@@ -516,7 +532,8 @@ class Follow(ManeuverBase):
self.env._terminate_in_goal = False
self._penalty_for_out_of_range = 200
self._penalty_for_change_lane = 200
self._enable_low_level_training_properties = True
global enable_additional_properties
self._enable_low_level_training_properties = enable_additional_properties
self._extra_action_weights_flag = True
def _init_param(self):
......
......@@ -2,7 +2,7 @@ from .maneuver_base import ManeuverBase
from env.simple_intersection.constants import *
import env.simple_intersection.road_geokinemetry as rd
from env.simple_intersection.features import extract_ego_features, extract_other_veh_features
from model_checker.simple_intersection import LTLProperty
from verifier.simple_intersection import LTLProperty
import numpy as np
......
from model_checker.scanner import Scanner
from model_checker.parser import Parser, Errors
from verifier.scanner import Scanner
from verifier.parser import Parser, Errors
class LTLPropertyBase(object):
......
......@@ -29,10 +29,10 @@
import sys
# Sean changed Scanner to model_checker.scanner
from model_checker.scanner import Token
from model_checker.scanner import Scanner
from model_checker.scanner import Position
# Sean changed Scanner to verifier.scanner
from verifier.scanner import Token
from verifier.scanner import Scanner
from verifier.scanner import Position
class ErrorRec(object):
......
from model_checker.simple_intersection import LTLProperty
from model_checker.simple_intersection.AP_dict import AP_dict_simple_intersection
from model_checker import Parser
from verifier.simple_intersection import LTLProperty
from verifier.simple_intersection.AP_dict import AP_dict_simple_intersection
from verifier import Parser
# TODO: Refactor LTL_test to model_checker part.
# TODO: Refactor LTL_test to verifier part.
def test_model_check(LTL, trace):
......
from model_checker import LTLPropertyBase, AtomicPropositionsBase
from verifier import LTLPropertyBase, AtomicPropositionsBase
from .AP_dict import AP_dict_simple_intersection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment