Beispiel #1
0
    def __init__(self, facility, config, economy):

        self.facility = facility
        self.economy = economy
        self.config = config
        hist_len = Utils.get_env_config()['sale_hist_len']
        pred_len = Utils.get_env_config()['demand_prediction_len']
        self.backlog_demand_hist = [0] * hist_len
        self.sale_hist = [0] * hist_len
        self.pred_sale = [0] * pred_len
        # print(self.sale_hist)
        self.total_backlog_demand = 0
Beispiel #2
0
    def _add_facility_features(self, state, _facility):
        # 对facility类型进行one-hot encoding
        facility_type = [0] * len(self.env.facility_types)
        facility_type[self.env.facility_types[_facility.__class__.__name__]] = 1
        state['facility_type'] = facility_type
        state['facility'] = _facility
        
        if isinstance(_facility, FacilityCell):
            state['facility_info'] = _facility.facility_info
            state['sku_info'] = {}
            state['is_positive_balance'] = 1 if _facility.economy.total_balance.total() > 0 else 0
        else:
            state['facility_info'] = _facility.facility.facility_info
            state['sku_info'] = _facility.sku_info
            state['is_positive_balance'] = 1 if _facility.facility.economy.total_balance.total() > 0 else 0
        
        # one-hot encoding of facility id
        facility_id_one_hot = [0] * len(self.env.world.facilities)
        facility_id_one_hot[_facility.id_num - 1] = 1
        state['facility_id'] = facility_id_one_hot

        # add echelon feature
        facility = _facility
        if isinstance(facility, ProductUnit):
            facility = _facility.facility
        if isinstance(facility, WarehouseCell):
            # reserve 0 for supplier 
            state['echelon_level'] = facility.echelon_level + 1
        elif isinstance(facility, SupplierCell):
            state['echelon_level'] = 0
        else:
            state['echelon_level'] = Utils.get_env_config()['total_echelons']
Beispiel #3
0
 def reset(self):
     self.open_orders = {}
     self.economy.total_units_received = 0
     self.economy.total_units_purchased = 0
     self.lost_product_value = 0
     self.products_received = 0
     self.latest_consumptions = [
         0
     ] * Utils.get_env_config()['consumption_hist_len']
Beispiel #4
0
 def __init__(self, facility, sources, economy):
     self.facility = facility
     self.sources = sources
     self.open_orders = {}
     self.economy = economy
     self.products_received = 0
     self.lost_product_value = 0
     self.latest_consumptions = [
         0
     ] * Utils.get_env_config()['consumption_hist_len']
Beispiel #5
0
 def _init_sale_pred(self):
     pred_len = Utils.get_env_config()['sale_oracle_len']
     return self.get_future_sales(pred_len)
Beispiel #6
0
 def get_future_demand(self, product_id):
     f_step = (self.step+Utils.get_env_config()['sale_hist_len'])%self.sale_sampler.total_span
     f_demand, _ = self.economy.market_demand(self.sale_sampler, product_id, f_step)
     return f_demand