Scheduling Package

The scheduling package provides batch process scheduling tools including State-Task Networks for production scheduling optimization.

Note

This is part of the modern modular structure of SPROCLIB.

Submodules

State-Task Network

State-Task Network for SPROCLIB

This module implements State-Task Network (STN) scheduling for batch processes with material balances, equipment constraints, and optimization.

Author: Thorsten Gressling <gressling@paramus.ai> License: MIT License

class sproclib.scheduling.state_task_network.StateTaskNetwork(name='STN')[source]

Bases: object

State-Task Network for batch process scheduling.

Parameters:

name (str)

__init__(name='STN')[source]

Initialize State-Task Network.

Parameters:

name (str) – Network name

add_state(name, capacity=inf, initial_amount=0.0, price=0.0, is_product=False)[source]

Add a state (material) to the network.

Parameters:
  • name (str) – State name

  • capacity (float) – Storage capacity

  • initial_amount (float) – Initial inventory

  • price (float) – Unit price/cost

  • is_product (bool) – Whether this is a final product

add_task(name, duration, inputs, outputs, suitable_units, variable_cost=0.0)[source]

Add a task to the network.

Parameters:
  • name (str) – Task name

  • duration (float) – Task duration

  • inputs (Dict[str, float]) – Input materials {state: amount}

  • outputs (Dict[str, float]) – Output materials {state: amount}

  • suitable_units (List[str]) – List of units that can perform this task

  • variable_cost (float) – Variable cost per batch

add_unit(name, capacity=1.0, unit_cost=0.0, availability=1.0)[source]

Add an equipment unit to the network.

Parameters:
  • name (str) – Unit name

  • capacity (float) – Unit capacity multiplier

  • unit_cost (float) – Operating cost per time unit

  • availability (float) – Unit availability (0-1)

optimize_schedule(time_horizon, objective='profit', demand=None, method='greedy')[source]

Optimize production schedule.

Parameters:
  • time_horizon (int) – Scheduling horizon [time units]

  • objective (str) – Optimization objective (‘profit’, ‘production’, ‘makespan’)

  • demand (Dict[str, float] | None) – Product demand requirements

  • method (str) – Solution method (‘greedy’, ‘milp’)

Returns:

Optimized schedule

Return type:

Dict[str, Any]

plot_schedule(figsize=(12, 6), show_inventories=True)[source]

Plot Gantt chart of the schedule.

Parameters:
  • figsize (Tuple[int, int]) – Figure size

  • show_inventories (bool) – Whether to show inventory plots

get_schedule_metrics()[source]

Calculate schedule performance metrics.

Returns:

Dictionary with performance metrics

Return type:

Dict[str, Any]

Quick Usage

Batch Process Scheduling:

from scheduling.state_task_network import StateTaskNetwork

# Create State-Task Network
stn = StateTaskNetwork("Batch Plant")

# Add states (materials)
stn.add_state("Raw_A", capacity=1000, initial_amount=500, price=10)
stn.add_state("Raw_B", capacity=800, initial_amount=300, price=15)
stn.add_state("Product", capacity=500, initial_amount=0, price=50)

# Add tasks (operations)
stn.add_task(
    name="React",
    duration=2.0,
    inputs={"Raw_A": 2.0, "Raw_B": 1.0},
    outputs={"Product": 1.0},
    suitable_units=["Reactor1", "Reactor2"]
)

# Add units (equipment)
stn.add_unit("Reactor1", capacity=100, unit_cost=50)
stn.add_unit("Reactor2", capacity=150, unit_cost=75)

# Optimize schedule
result = stn.optimize_schedule(
    time_horizon=24,
    objective='profit',
    demand={"Product": 200}
)

# Visualize schedule
stn.plot_schedule()

print(f"Total profit: ${result['profit']:.2f}")
print(f"Schedule feasible: {result['feasible']}")