from keras.optimizers import Adam, SGD, Nadam
from keras.models import Sequential, load_model

colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
app_dir = os.path.abspath('')
os.chdir('..\..\..')
from pysim.models.model_power import Mod_Power, Mod_Battery, Mod_Motor
from pysim.models.model_vehicle import Mod_Body, Mod_Veh
from pysim.models.model_environment import Mod_Env
from pysim.models.model_maneuver import Mod_Driver, Mod_Behavior
from pysim.sub_util.sub_type_def import type_DataLog, type_pid_controller
from pysim.sub_util.sub_utilities import Filt_LowPass
os.chdir(app_dir)
# import application modules
import get_data
get_data.set_dir(os.path.abspath('.\driving_data'))
DrivingData = get_data.load_mat('CfData1.mat')

get_data.set_dir(os.path.abspath('.\driver_data'))
DriverDataRaw = get_data.load_mat('Results_Sils_Learning.mat')
DriverDataRaw['BaseMap_InitDis'] = np.transpose(
    DriverDataRaw['BaseMap_InitDis'])
DriverDataRaw['BaseMap_CoastDis'] = np.transpose(
    DriverDataRaw['BaseMap_CoastDis'])

DriverDataKh = copy.deepcopy(DriverDataRaw)
DriverDataKh['LrnVec_Param_AccSlopeCf'] = np.expand_dims(np.transpose(
    DriverDataKh['MapArry_AccSlopeCf'][0, :]),
                                                         axis=1)
DriverDataKh['LrnVec_Param_RelDisAdj'] = np.expand_dims(np.transpose(
    DriverDataKh['MapArry_AdjDis'][0, :]),
Esempio n. 2
0
~~~~~~~~~~~~~
* kyunghan <*****@*****.**>

Description
~~~~~~~~~~~~~
* Intelligent driver model

Update
~~~~~~~~~~~~~
* [19/02/22] - Initial draft design
"""
import numpy as np
import math
import os
import get_data
get_data.set_dir(os.path.abspath('.\driver_data'))
EffectProbIndex = get_data.load_mat('EffectiveProbIndex.mat')['ParLrn_ProbVec']


def EffectiveProbability(Index, IndexVectorArray, Std):
    "Calculation of effective probability"
    CoastIndexLength = np.size(IndexVectorArray)
    ProbVec = np.arange(CoastIndexLength, dtype='float')
    # Gaussian distribution
    for i in range(CoastIndexLength):
        VecVal = 1 / (Std * math.sqrt(2 * math.pi)) * np.exp(-0.5 * (
            (Index - IndexVectorArray[i]) / Std)**2)
        ProbVec[i, ] = VecVal[0, 0]
    # Normalization
    ProbSum = np.sum(ProbVec)
    EffProb = ProbVec / ProbSum