diff --git a/CHANGELOG.md b/CHANGELOG.md index c4edd0c..bea879c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.0.8] -- 2022-06-27 + +### Changed +- Removed cost summary output and ``print_cost_summary`` option from ``sim_io.write_results()`` + ## [0.0.7] -- 2022-06-27 ### Fixed diff --git a/README.md b/README.md index e630d44..82e3d0c 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ Some Examples Solve the EOQ problem with a fixed cost of 8, a holding cost of 0.225, and a demand rate of 1300 (Example 3.1 in *FoSCT*): -.. doctest:: - >>> from stockpyl.eoq import economic_order_quantity >>> Q, cost = economic_order_quantity(fixed_cost=8, holding_cost=0.225, demand_rate=1300) >>> Q diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index 5b878aa..6aa9b37 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index e134c7c..4699af2 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/tutorial/tutorial_sim.rst b/docs/tutorial/tutorial_sim.rst index c431e75..dd7e307 100644 --- a/docs/tutorial/tutorial_sim.rst +++ b/docs/tutorial/tutorial_sim.rst @@ -45,7 +45,7 @@ an order lead time of 0, and a shipment lead time of 1. ... shipment_lead_time=1 ... ) >>> _ = simulation(network=network, num_periods=4, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=4, columns_to_print='basic', print_cost_summary=False) + >>> write_results(network=network, num_periods=4, columns_to_print='basic') t i=0 IO:EXT OQ:EXT IS:EXT OS:EXT IL --- ----- -------- -------- -------- -------- ---- 0 12 12 0 12 1 @@ -262,7 +262,7 @@ Both nodes have a (shipment) lead time of 1. ... shipment_lead_time=[1, 1] ... ) >>> _ = simulation(network=network, num_periods=4, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=4, columns_to_print='basic', print_cost_summary=False) + >>> write_results(network=network, num_periods=4, columns_to_print='basic') t i=0 IO:1 OQ:EXT IS:EXT OS:1 IL i=1 IO:EXT OQ:0 IS:0 OS:EXT IL --- ----- ------ -------- -------- ------ ---- ----- -------- ------ ------ -------- ---- 0 42 50 0 42 8 42 42 0 42 8 @@ -433,8 +433,7 @@ columns: ... network=network, ... num_periods=10, ... periods_to_print=list(range(3, 9)), - ... columns_to_print=['OQ', 'IL', 'TC'], - ... print_cost_summary=False + ... columns_to_print=['OQ', 'IL', 'TC'] ... ) t i=1 OQ:3 OQ:4 IL TC i=2 OQ:3 IL TC i=3 OQ:EXT IL TC i=4 OQ:EXT IL TC --- ----- ------ ------ ---- ---- ----- ------ ---- ---- ----- -------- ---- ---- ----- -------- ---- ---- @@ -473,8 +472,7 @@ of allowable strings.) Shortcuts and column names can be combined in one list: ... network=network, ... num_periods=10, ... periods_to_print=list(range(3, 9)), - ... columns_to_print=['OQ', 'IL', 'costs'], - ... print_cost_summary=False + ... columns_to_print=['OQ', 'IL', 'costs'] ... ) t i=1 OQ:3 OQ:4 IL HC SC TC i=2 OQ:3 IL HC SC TC i=3 OQ:EXT IL HC SC TC i=4 OQ:EXT IL HC SC TC --- ----- ------ ------ ---- ---- ---- ---- ----- ------ ---- ---- ---- ---- ----- -------- ---- ---- ---- ---- ----- -------- ---- ---- ---- ---- @@ -556,7 +554,7 @@ disruptions. First, type-OP disruptions: ... ) >>> T = 100 >>> _ = simulation(network=network, num_periods=T, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL'], print_cost_summary=False) + >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL']) t i=1 DISR IO:2 OQ:EXT IS:EXT OS:2 IL i=2 DISR IO:EXT OQ:1 IS:1 OS:EXT IL --- ----- ------ ------ -------- -------- ------ ---- ----- ------ -------- ------ ------ -------- ---- 7 False 19 19 14 19 6 False 19 19 14 19 6 @@ -580,7 +578,7 @@ Next, type-SP disruptions: >>> network.get_node_from_index(2).disruption_process.disruption_type='SP' >>> _ = simulation(network=network, num_periods=T, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL', 'ODI'], print_cost_summary=False) + >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL', 'ODI']) t i=1 DISR IO:2 OQ:EXT IS:EXT OS:2 IL ODI:2 i=2 DISR IO:EXT OQ:1 IS:1 OS:EXT IL ODI:EXT --- ----- ------ ------ -------- -------- ------ ---- ------- ----- ------ -------- ------ ------ -------- ---- --------- 7 False 19 19 14 19 6 0 False 19 19 14 19 6 0 @@ -602,7 +600,7 @@ Next, type-TP disruptions: >>> network.get_node_from_index(2).disruption_process.disruption_type='TP' >>> _ = simulation(network=network, num_periods=T, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'ISPL', 'OS', 'IL'], print_cost_summary=False) + >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'ISPL', 'OS', 'IL']) t i=1 DISR IO:2 OQ:EXT IS:EXT ISPL:EXT OS:2 IL i=2 DISR IO:EXT OQ:1 IS:1 ISPL:1 OS:EXT IL --- ----- ------ ------ -------- -------- ---------- ------ ---- ----- ------ -------- ------ ------ -------- -------- ---- 7 False 19 19 14 [19.0] 19 6 False 19 19 14 [19.0] 19 6 @@ -624,7 +622,7 @@ Finally, type-RP disruptions: >>> network.get_node_from_index(2).disruption_process.disruption_type='RP' >>> _ = simulation(network=network, num_periods=T, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL', 'ISPL', 'IDI'], print_cost_summary=False) + >>> write_results(network=network, num_periods=T, periods_to_print=list(range(7, 16)), columns_to_print=['DISR', 'IO', 'OQ', 'IS', 'OS', 'IL', 'ISPL', 'IDI']) t i=1 DISR IO:2 OQ:EXT IS:EXT ISPL:EXT IDI:EXT OS:2 IL i=2 DISR IO:EXT OQ:1 IS:1 ISPL:1 IDI:1 OS:EXT IL --- ----- ------ ------ -------- -------- ---------- --------- ------ ---- ----- ------ -------- ------ ------ -------- ------- -------- ---- 7 False 19 19 14 [19.0] 0 19 6 False 19 19 14 [19.0] 0 19 6 @@ -715,7 +713,7 @@ and :math:`(-x)^+` is the backorders). ... ) >>> T = 100 >>> _ = simulation(network=network, num_periods=T, rand_seed=42, progress_bar=False) - >>> write_results(network=network, num_periods=T, periods_to_print=list(range(6)), columns_to_print=['basic', 'costs'], print_cost_summary=False) + >>> write_results(network=network, num_periods=T, periods_to_print=list(range(6)), columns_to_print=['basic', 'costs']) t i=0 IO:EXT OQ:EXT IS:EXT OS:EXT IL HC SC TC --- ----- -------- -------- -------- -------- ---- ---- ------- ------- 0 18 18 0 17 -1 0 10 10 diff --git a/src/stockpyl/sim_io.py b/src/stockpyl/sim_io.py index e2969c5..4a25c00 100644 --- a/src/stockpyl/sim_io.py +++ b/src/stockpyl/sim_io.py @@ -80,7 +80,7 @@ def write_results(network, num_periods, periods_to_print=None, columns_to_print=None, - print_cost_summary=True, write_csv=False, csv_filename=None): + write_csv=False, csv_filename=None): """Write the results of a simulation to the console, as well as to a CSV file if requested. Parameters @@ -103,9 +103,6 @@ def write_results(network, num_periods, periods_to_print=None, columns_to_print= * ``'all'``: prints all columns (equivalent to setting ``columns_to_print=None``) Unrecognized strings are ignored. If omitted, will print all columns (the default). - print_cost_summary : bool, optional - ``True`` to print the total cost per period and over the horizon after the state-variable table, - ``False`` otherwise. Optional; default = ``True``. write_csv : bool, optional ``True`` to write to CSV file, ``False`` otherwise. Optional; default = ``False``. csv_filename : str, optional @@ -239,13 +236,6 @@ def write_results(network, num_periods, periods_to_print=None, columns_to_print= # Write results to screen print(tabulate(results, headers=headers)) - # Average and total cost - if print_cost_summary: - total_cost = np.sum([n.state_vars[t].total_cost_incurred for n in network.nodes - for t in range(num_periods)]) - print("\nTotal avg. cost per period = {:f}".format(1.0 * np.sum(total_cost) / num_periods)) - print("Total horizon cost = {:f}".format(1.0 * np.sum(total_cost))) - # CSV output if write_csv: with open(csv_filename, 'w') as csvFile: