Пример #1
0
 def __init__(self, num_stages = 12,\
              ):
     self.num_stages = num_stages
     self.stations = Stations()
     self.action_L = self.stations.pmin
     self.action_H = self.stations.pmax
     self.action_space = abox.ABox(self.action_L,
                                   self.action_H,
                                   dtype=np.float64)
     self.observation_space = mbox.MBox(self.stations.num_cars,
                                        self.stations.num_stations)
     #self.observation= np.multiply(np.ones(self.stations.num_stations), self.stations.num_cars/self.num_stations)
     self.t = 0
Пример #2
0
 def __init__(self,
              num_stations=N_def,
              num_cars=MAX_CARS_def,
              min_price=pmin_def,
              travel_time_btwn_stat=T_def,
              a=a_def,
              b=b_def):
     self.__version__ = "0.1.0"
     logging.info("CarsharingEnv - Version {}".format(self.__version__))
     # General variables defining the environment
     self.N = num_stations  # Number of stations
     self.MAX_CARS = num_cars  # Max number of cars in the system
     self.set_pmin = min_price
     #        self.T = np.array([ ])
     #        self.T=np.random.randint(1,4, size=(self.N, self.N))
     self.T = travel_time_btwn_stat
     self.kmax = np.max(self.T)
     self.a = a
     self.b = b
     self.pmin = min_price
     self.pmax = np.empty(self.N)
     self.pmax = self.a / (
         -1 * self.b
     ) - 0.1  # -1 set the price such that the expected demand cannot be negative
     self.pmax = np.around(self.pmax, 1)
     self.dmin = self.D(self.pmax)
     self.dmax = self.D(self.pmin)
     self.Nik = []
     for i in range(self.N):
         self.Nik.append(
             [np.where(self.T[:, i] == k) for k in range(1, self.kmax + 1)])
     self.action_space = spaces.Box(self.pmin, self.pmax, dtype=np.float32)
     self.s = spaces.Box(0,
                         self.kmax,
                         shape=(self.N, self.kmax),
                         dtype=np.uint8)
     self.x = mbox.MBox(self.MAX_CARS, self.N)
     self.observation_space = spaces.Tuple((self.x, self.s))
     self.t = 0
Пример #3
0
    def __init__(self,
                 num_stations=N_def,
                 num_cars=MAX_CARS_def,
                 aa_min_price=aa_pmin_def,
                 aa_max_price=aa_pmax_def,
                 ab_min_price=ab_pmin_def,
                 ab_max_price=ab_pmax_def,
                 aa=aa_def,
                 ab=ab_def,
                 bb=bb_def,
                 ba=ba_def,
                 discount_rate=discount_rate_def,
                 num_stages=num_stages_def,
                 aa_epsSupL=aa_epsSupL_def,
                 aa_epsSupH=aa_epsSupH_def,
                 ab_epsSupL=ab_epsSupL_def,
                 ab_epsSupH=ab_epsSupH_def):
        self.__version__ = "0.1.0"
        logging.info("CarsharingEnv - Version {}".format(self.__version__))
        self.N = num_stations  # Number of stations
        self.MAX_CARS = num_cars  # Max number of cars in the system

        #return trip demand model
        self.aa = aa
        self.bb = bb

        #one way trip demand model
        self.ab = ab
        self.ba = ba

        #return trips epsilon support
        self.aa_epsSupL = aa_epsSupL
        self.aa_epsSupH = aa_epsSupH

        #one trips epsilon support
        self.ab_epsSupL = ab_epsSupL
        self.ab_epsSupH = ab_epsSupH

        #return min/max price
        self.aa_pmin = aa_min_price
        self.aa_pmax = np.minimum(
            np.around((self.aa + self.aa_epsSupL) / (-1 * self.bb), 1),
            aa_max_price)

        #return fixed demand and price for one-way station
        self.aa_p = (self.aa_pmin + self.aa_pmax) * 0.5
        self.aa_d = self.DAA(self.aa_p)

        #one_way trips min/max price
        self.ab_pmin = ab_min_price
        self.ab_pmax = np.minimum(
            np.around((self.ab + self.ab_epsSupL) / (-1 * self.ba), 1),
            ab_max_price)

        self.aa_dmin = self.DAA(self.aa_pmax)
        self.aa_dmax = self.DAA(self.aa_pmin)

        self.ab_dmin = self.DAB(self.ab_pmax)
        self.ab_dmax = self.DAB(self.ab_pmin)

        #for the actions it is better to separate AA and A_all_other, since AAs are fixed
        # theta variables !!
        #easy need to create a variable
        self.action_L = np.concatenate((self.ab_dmin, np.zeros(self.N)))
        self.action_H = np.concatenate(
            (self.ab_dmax, np.multiply(np.ones(self.N), self.MAX_CARS)))
        self.action_space = abox.ABox(self.action_L,
                                      self.action_H,
                                      dtype=np.float32)
        #        self.s=spaces.Box(0, self.kmax,shape=(self.N,self.kmax), dtype=np.uint8)
        #        self.observation_space = spaces.Tuple((self.x,self.s))
        self.observation = np.multiply(
            np.ones(self.N),
            self.MAX_CARS / self.N)  #mbox.randomize(self.MAX_CARS, self.N)
        self.observation_space = mbox.MBox(self.MAX_CARS, self.N)
        self.t = 0