Skip to content

Commit

Permalink
Update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
LarrySnyder committed Jun 27, 2022
1 parent 40d8de9 commit 724f0e6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
20 changes: 9 additions & 11 deletions docs/tutorial/tutorial_sim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
--- ----- ------ ------ ---- ---- ----- ------ ---- ---- ----- -------- ---- ---- ----- -------- ---- ----
Expand Down Expand Up @@ -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
--- ----- ------ ------ ---- ---- ---- ---- ----- ------ ---- ---- ---- ---- ----- -------- ---- ---- ---- ---- ----- -------- ---- ---- ---- ----
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions src/stockpyl/sim_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 724f0e6

Please sign in to comment.