def demand_var(info_rv):
    pdf = sum([
        dirac.f * pacal.PoissonDistr(dirac.a).get_piecewise_pdf()
        for dirac in info_rv.get_piecewise_pdf().getDiracs()
    ])
    d_rv = pacal.DiscreteDistr([d.a for d in pdf.getDiracs()],
                               [d.f for d in pdf.getDiracs()])
    return d_rv.var()
def test_case_var(info_states):
    weight = 1 / len(info_states)
    pdf = sum([
        weight * pacal.PoissonDistr(info_state).get_piecewise_pdf()
        for info_state in info_states
    ])
    d_rv = pacal.DiscreteDistr([d.a for d in pdf.getDiracs()],
                               [d.f for d in pdf.getDiracs()])
    return d_rv.var()
예제 #3
0
 def usage(self, o):
     return pacal.PoissonDistr(o * self.scale, trunk_eps=self.trunk)
예제 #4
0
    merged_fn = "{}_{}.pickle".format(date.today().isoformat(),
                                      configs[0].label)
    results.to_pickle(merged_fn)
    for config in configs:
        os.remove(config.results_fn)


if __name__ == "__main__":
    gamma = 0.9
    lead_time = 0
    horizon = 2
    info_state_rvs = [
        pacal.ConstDistr(0),
        pacal.ConstDistr(0),
        #pacal.DiscreteDistr([1, 2, 19, 20], [0.25, 0.25, 0.25, 0.25])
        pacal.PoissonDistr(5, trunk_eps=1e-3)
    ]
    holding_cost = 1
    backlogging_cost = 10
    setup_cost = 5
    unit_price = 0
    usage_model = PoissonUsageModel(scale=1)
    # usage_model = lambda o: pacal.ConstDistr(o)
    # usage_model = lambda o: pacal.PoissonDistr(o, trunk_eps=1e-3)
    # sage_model = None
    model = StationaryOptModel(gamma,
                               lead_time,
                               info_state_rvs,
                               holding_cost,
                               backlogging_cost,
                               setup_cost,
def poisson_usage(o):
    return pacal.PoissonDistr(o, trunk_eps=1e-3)
예제 #6
0
rv_2_18 = pacal.DiscreteDistr([2, 18], [0.5, 0.5])
rv_0_20 = pacal.DiscreteDistr([0, 20], [0.5, 0.5])
rv_8_16 = pacal.DiscreteDistr([8, 16], [0.5, 0.5])

test_cases_set_all = {
    "E[Demand] 10": rv_10_10,
    "E[Demand] 8, 12": rv_8_12,
    "E[Demand] 6, 14": rv_6_14,
    "E[Demand] 4, 16": rv_4_16,
    "E[Demand] 2, 18": rv_2_18,
    "E[Demand] 0, 20": rv_0_20
}

info_horizons = [1]
usage_models = {
    "Poisson": (lambda o: pacal.PoissonDistr(o, trunk_eps=1e-3), 1)
}
demand_models = {
    "E[Demand] 6, 14": rv_6_14,
}

fn = "batch_mdp_results_non_convex_cases_action_inc_v2_20191003_01.pickle"

setup_cost = 50
gamma = 0.9
lead_time = 0
holding_cost = 1
backlogging_cost = 10
unit_price = 0
action_inc = 0.1
예제 #7
0
rv_10_10 = pacal.DiscreteDistr([10], [1])
rv_8_12 = pacal.DiscreteDistr([8, 12], [0.5, 0.5])
rv_7_13 = pacal.DiscreteDistr([7, 13], [0.5, 0.5])
rv_6_14 = pacal.DiscreteDistr([6, 14], [0.5, 0.5])
rv_5_15 = pacal.DiscreteDistr([5, 15], [0.5, 0.5])
rv_4_16 = pacal.DiscreteDistr([4, 16], [0.5, 0.5])
rv_2_18 = pacal.DiscreteDistr([2, 18], [0.5, 0.5])
rv_0_20 = pacal.DiscreteDistr([0, 20], [0.5, 0.5])
rv_8_16 = pacal.DiscreteDistr([8, 16], [0.5, 0.5])

configs = []

if __name__ == "__main__":
    i = 0
    for horizon in [1, 2, 3, 4]:
        for rv in [rv_4_16, pacal.PoissonDistr(5, trunk_eps=1e-3)]:
            s_rv = [rv_0] * horizon + [rv]
            s_rv = s_rv if horizon else s_rv + [rv_0]
            ns_rv = [s_rv] * 7

            ns_config = ns_model.ModelConfig(
                gamma=0.9,
                lead_time=0,
                holding_cost=1,
                backlogging_cost=10,
                setup_cost=50,
                unit_price=0,
                usage_model=PoissonUsageModel(scale=1),
                ns_info_state_rvs=ns_rv,
                horizon=horizon,
                label="non_stationary_test",