Exemplo n.º 1
0
    def test_shortage_cost(self):
        """ Test shortage cost when a backlog has been recorded. """

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim[0]:
            if int(period[0].get("shortage_cost")) > 0:
                self.assertGreater(int(period[0].get("backlog")), 0)
Exemplo n.º 2
0
def main():
    start_time = time.time()

    orders_analysis = model_inventory.analyse_orders_abcxyz_from_file(
        file_path="data.csv", z_value=Decimal(1.28), reorder_cost=Decimal(5000), file_type="csv"
    )

    sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders, runs=1, period_length=12)

    sim_window = simulate.summarize_window(simulation_frame=sim, period_length=12)

    sim_frame = simulate.summarise_frame(sim_window)

    optimised = simulate.optimise_service_level(
        service_level=95.0,
        frame_summary=sim_frame,
        orders_analysis=orders_analysis.orders,
        runs=1,
        percentage_increase=1.30,
    )
    for s in optimised:
        print(s.orders_summary())

    end_time = time.time()
    elapsed = end_time - start_time
    print(elapsed)
Exemplo n.º 3
0
def main():
    start_time = time.time()

    orders_analysis = model_inventory.analyse_orders_abcxyz_from_file(
        file_path="data.csv",
        z_value=Decimal(1.28),
        reorder_cost=Decimal(5000),
        file_type="csv")

    sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders,
                                   runs=1,
                                   period_length=12)

    sim_window = simulate.summarize_window(simulation_frame=sim,
                                           period_length=12)

    sim_frame = simulate.summarise_frame(sim_window)

    optimised = simulate.optimise_service_level(
        service_level=95.0,
        frame_summary=sim_frame,
        orders_analysis=orders_analysis.orders,
        runs=1,
        percentage_increase=1.30)
    for s in optimised:
        print(s.orders_summary())

    end_time = time.time()
    elapsed = end_time - start_time
    print(elapsed)
Exemplo n.º 4
0
    def test_po_raised_regex(self):

        po_regex = re.compile('[P][O] \d+')

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim[0]:
            if int(period[0].get("closing_stock")) == 0 and int(period[0].get("backlog")) > 0:
                self.assertRegex(period[0].get("po_raised"), expected_regex=po_regex, msg='True')
Exemplo n.º 5
0
    def test_po_raised_regex(self):

        po_regex = re.compile('[P][O] \d+')

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0 and int(period[0].get("backlog")) > 0:
                self.assertRegex(period[0].get("po_raised"), expected_regex=po_regex, msg='True')
Exemplo n.º 6
0
    def test_shortage_cost_zero(self):
        """ Ensures that there is 0 shortage cost when a backlog has not been recorded."""

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis,
                                       runs=10, period_length=12)
        for period in sim[0]:
            if int(period[0].get("backlog")) == 0:
                self.assertEqual(int(period[0].get("shortage_cost")), 0)
Exemplo n.º 7
0
    def test_shortage_cost(self):

        """ Test shortage cost when a backlog has been recorded. """

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim:
            if int(period[0].get("shortage_cost")) > 0:
                self.assertGreater(int(period[0].get("backlog")), 0)
Exemplo n.º 8
0
    def test_po_quantity_zero(self):
        """Ensures a purchase order is raised if the closing stock is 0. """

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim[0]:
            if int(period[0].get("closing_stock")) == 0:
               # print(period[0].get("po_quantity"))
                self.assertGreater(int(period[0].get("po_quantity")), 0)
Exemplo n.º 9
0
    def setUp(self):
        self.__skus = ['KR202-209', 'KR202-210', 'KR202-211']

        self.__orders_analysis = analyse_orders_abcxyz_from_file(file_path=ABS_FILE_PATH['COMPLETE_CSV_SM'],
                                                                 z_value=Decimal(1.28),
                                                                 reorder_cost=Decimal(5000),
                                                                 file_type="csv",
                                                                 length=12)
        self.sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
Exemplo n.º 10
0
    def test_po_quantity_zero(self):

        """Ensures a purchase order is raised if the closing stock is 0. """

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1, period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0:
               # print(period[0].get("po_quantity"))
                self.assertGreater(int(period[0].get("po_quantity")), 0)
Exemplo n.º 11
0
    def test_shortage_cost_zero(self):

        """ Ensures that there is 0 shortage cost when a backlog has not been recorded."""

        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis,
                                       runs=1, period_length=12)
        for period in sim:
           # print(period)
            if int(period[0].get("backlog")) == 0:
                self.assertEqual(int(period[0].get("shortage_cost")), 0)
    def test_summarize_simulation(self):
        orders_analysis = analyse_orders_abcxyz_from_file(
            file_path=ABS_FILE_PATH["COMPLETE_CSV_SM"],
            z_value=Decimal(1.28),
            reorder_cost=Decimal(5000),
            file_type="csv",
        )

        simulation_windows = simulate.run_monte_carlo(orders_analysis=orders_analysis, runs=1, period_length=12)
        collect_sim = []
        for i in simulate.summarize_window(simulation_frame=simulation_windows):
            collect_sim.append(i)
        self.assertEqual(len(collect_sim), 39)
    def test_run_simulation(self):
        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data2.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = model_inventory.analyse_orders_abcxyz_from_file(file_path=abs_file_path,
                                                                          z_value=Decimal(1.28),
                                                                          reorder_cost=Decimal(5000),
                                                                          file_type="csv")

        simulation_windows = simulate.run_monte_carlo(orders_analysis=orders_analysis, runs=1)

        self.assertEqual(len(simulation_windows), 384)
Exemplo n.º 14
0
    def test_po_quantity_zero(self):

        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = analyse_orders_abcxyz_from_file(file_path=abs_file_path, z_value=Decimal(1.28),
                                                          reorder_cost=Decimal(5000), file_type="csv")

        sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders, runs=1, period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0:
                self.assertGreater(int(period[0].get("po_quantity")), 0)
    def test_summarize_simulation(self):
        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data2.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = analyse_orders_abcxyz_from_file(file_path=abs_file_path, z_value=Decimal(1.28),
                                                          reorder_cost=Decimal(5000), file_type="csv")

        simulation_windows = simulate.run_monte_carlo(orders_analysis=orders_analysis, runs=1, period_length=12)
        collect_sim = []
        for i in simulate.summarize_window(simulation_frame=simulation_windows):
            collect_sim.append(i)

        self.assertEqual(len(collect_sim), 32)
Exemplo n.º 16
0
    def test_po_raised_regex(self):

        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        po_regex = re.compile('[P][O] \d+')
        orders_analysis = analyse_orders_abcxyz_from_file(file_path=abs_file_path, z_value=Decimal(1.28),
                                                          reorder_cost=Decimal(5000), file_type="csv")

        sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders, runs=1, period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0 and int(period[0].get("backlog")) > 0:
                self.assertRegex(period[0].get("po_raised"), expected_regex=po_regex, msg='True')
    def test_run_simulation(self):
        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = model_inventory.analyse_orders_abcxyz_from_file(
            file_path=abs_file_path,
            z_value=Decimal(1.28),
            reorder_cost=Decimal(5000),
            file_type="csv")

        simulation_windows = simulate.run_monte_carlo(
            orders_analysis=orders_analysis.orders, runs=1)

        self.assertEqual(len(simulation_windows), 384)
Exemplo n.º 18
0
    def quick_test(self):
        sim = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis,
                                       runs=100, period_length=12)
        sim_window = simulate.summarize_window(simulation_frame=sim, period_length=12)

        #for item in sim:
        #    for s in item:
        #        if s[0].get('sku_id')=='KR202-209':
        #            print(s)
        #print(sim_window)
        frame_summary = simulate.summarise_frame(sim_window)
        #print(frame_summary)
        #for item in frame_summary:
        #    if item.get('sku_id')=='KR202-209':
        #        print(item)
        print(frame_summary)
Exemplo n.º 19
0
    def test_po_quantity_zero(self):

        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = analyse_orders_abcxyz_from_file(
            file_path=abs_file_path,
            z_value=Decimal(1.28),
            reorder_cost=Decimal(5000),
            file_type="csv")

        sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders,
                                       runs=1,
                                       period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0:
                self.assertGreater(int(period[0].get("po_quantity")), 0)
    def test_summarize_simulation(self):
        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        orders_analysis = analyse_orders_abcxyz_from_file(
            file_path=abs_file_path,
            z_value=Decimal(1.28),
            reorder_cost=Decimal(5000),
            file_type="csv")

        simulation_windows = simulate.run_monte_carlo(
            orders_analysis=orders_analysis.orders, runs=1, period_length=12)
        collect_sim = []
        for i in simulate.summarize_window(
                simulation_frame=simulation_windows):
            collect_sim.append(i)

        self.assertEqual(len(collect_sim), 32)
Exemplo n.º 21
0
    def test_po_raised_regex(self):

        app_dir = os.path.dirname(__file__, )
        rel_path = 'supplychainpy/data.csv'
        abs_file_path = os.path.abspath(os.path.join(app_dir, '..', rel_path))

        po_regex = re.compile('[P][O] \d+')
        orders_analysis = analyse_orders_abcxyz_from_file(
            file_path=abs_file_path,
            z_value=Decimal(1.28),
            reorder_cost=Decimal(5000),
            file_type="csv")

        sim = simulate.run_monte_carlo(orders_analysis=orders_analysis.orders,
                                       runs=1,
                                       period_length=12)
        for period in sim:
            if int(period[0].get("closing_stock")) == 0 and int(
                    period[0].get("backlog")) > 0:
                self.assertRegex(period[0].get("po_raised"),
                                 expected_regex=po_regex,
                                 msg='True')
    def test_run_simulation(self):

        simulation_windows = simulate.run_monte_carlo(orders_analysis=self.__orders_analysis, runs=1)

        self.assertEqual(len(simulation_windows), 468)