Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp
- Enhanced documentation in `flixopt/types.py` with comprehensive examples and dimension explanation table
- Clarified Effect type docstrings - Effect types are dicts, but single numeric values work through union types
- Added clarifying comments in `effects.py` explaining parameter handling and transformation
- Improved OnOffParameters attribute documentation
- Improved ActivityParameters attribute documentation
- Updated getting-started guide with loguru examples
- Updated `config.py` docstrings for loguru integration

Expand Down Expand Up @@ -215,7 +215,7 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp
- Improved `summary.yaml` to use a compacted list representation for periods and scenarios

### 🐛 Fixed
- Using `switch_on_total_max` with periods or scenarios failed
- Using `startup_total_max` with periods or scenarios failed

### 📝 Docs
- Add more comprehensive `CONTRIBUTE.md`
Expand Down Expand Up @@ -467,7 +467,7 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir
**Variable Renaming in Results:**

- Investment binary variable: `is_invested` → `invested` in `InvestmentModel`
- Switch tracking variables in `OnOffModel`:
- Switch tracking variables in `ActivityModel`:
- `switch_on` → `switch|on`
- `switch_off` → `switch|off`
- `switch_on_nr` → `switch|count`
Expand Down Expand Up @@ -759,18 +759,18 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir

### ✨ Added
- Python 3.13 support added
- Logger warning if relative_minimum is used without on_off_parameters in Flow
- Logger warning if relative_minimum is used without activity_parameters in Flow
- Greatly improved internal testing infrastructure by leveraging linopy's testing framework

### 💥 Breaking Changes
- Restructured the modeling of the On/Off state of Flows or Components
- Variable renaming: `...|consecutive_on_hours` → `...|ConsecutiveOn|hours`
- Variable renaming: `...|consecutive_off_hours` → `...|ConsecutiveOff|hours`
- Constraint renaming: `...|consecutive_on_hours_con1` → `...|ConsecutiveOn|con1`
- Variable renaming: `...|consecutive_active_hours` → `...|ConsecutiveOn|hours`
- Variable renaming: `...|consecutive_inactive_hours` → `...|ConsecutiveOff|hours`
- Constraint renaming: `...|consecutive_active_hours_con1` → `...|ConsecutiveOn|con1`
- Similar pattern for all consecutive on/off constraints

### 🐛 Fixed
- Fixed the lower bound of `flow_rate` when using optional investments without OnOffParameters
- Fixed the lower bound of `flow_rate` when using optional investments without ActivityParameters
- Fixed bug that prevented divest effects from working
- Added lower bounds of 0 to two unbounded vars (numerical improvement)

Expand All @@ -779,7 +779,7 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir
## [2.0.1] - 2025-04-10

### ✨ Added
- Logger warning if relative_minimum is used without on_off_parameters in Flow
- Logger warning if relative_minimum is used without activity_parameters in Flow

### 🐛 Fixed
- Replace "|" with "__" in filenames when saving figures (Windows compatibility)
Expand Down Expand Up @@ -813,9 +813,9 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir

**Variable Structure:**
- Restructured the modeling of the On/Off state of Flows or Components
- Variable renaming: `...|consecutive_on_hours` → `...|ConsecutiveOn|hours`
- Variable renaming: `...|consecutive_off_hours` → `...|ConsecutiveOff|hours`
- Constraint renaming: `...|consecutive_on_hours_con1` → `...|ConsecutiveOn|con1`
- Variable renaming: `...|consecutive_active_hours` → `...|ConsecutiveOn|hours`
- Variable renaming: `...|consecutive_inactive_hours` → `...|ConsecutiveOff|hours`
- Constraint renaming: `...|consecutive_active_hours_con1` → `...|ConsecutiveOn|con1`
- Similar pattern for all consecutive on/off constraints

### 🔥 Removed
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide/mathematical-notation/elements/Flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $$
$$


This mathematical formulation can be extended by using [OnOffParameters](../features/OnOffParameters.md)
This mathematical formulation can be extended by using [ActivityParameters](../features/ActivityParameters.md)
to define the on/off state of the Flow, or by using [InvestParameters](../features/InvestParameters.md)
to change the size of the Flow from a constant to an optimization variable.

Expand All @@ -34,7 +34,7 @@ to change the size of the Flow from a constant to an optimization variable.
Flow formulation uses the following modeling patterns:

- **[Scaled Bounds](../modeling-patterns/bounds-and-states.md#scaled-bounds)** - Basic flow rate bounds (equation $\eqref{eq:flow_rate}$)
- **[Scaled Bounds with State](../modeling-patterns/bounds-and-states.md#scaled-bounds-with-state)** - When combined with [OnOffParameters](../features/OnOffParameters.md)
- **[Scaled Bounds with State](../modeling-patterns/bounds-and-states.md#scaled-bounds-with-state)** - When combined with [ActivityParameters](../features/ActivityParameters.md)
- **[Bounds with State](../modeling-patterns/bounds-and-states.md#bounds-with-state)** - Investment decisions with [InvestParameters](../features/InvestParameters.md)

---
Expand All @@ -48,15 +48,15 @@ Flow formulation uses the following modeling patterns:
- `relative_minimum`, `relative_maximum`: Relative bounds $\text{p}^{\text{L}}_{\text{rel}}, \text{p}^{\text{U}}_{\text{rel}}$
- `effects_per_flow_hour`: Operational effects (costs, emissions, etc.)
- `invest_parameters`: Optional investment modeling (see [InvestParameters](../features/InvestParameters.md))
- `on_off_parameters`: Optional on/off operation (see [OnOffParameters](../features/OnOffParameters.md))
- `activity_parameters`: Optional on/off operation (see [ActivityParameters](../features/ActivityParameters.md))

See the [`Flow`][flixopt.elements.Flow] API documentation for complete parameter list and usage examples.

---

## See Also

- [OnOffParameters](../features/OnOffParameters.md) - Binary on/off operation
- [ActivityParameters](../features/ActivityParameters.md) - Binary on/off operation
- [InvestParameters](../features/InvestParameters.md) - Variable flow sizing
- [Bus](../elements/Bus.md) - Flow balance constraints
- [LinearConverter](../elements/LinearConverter.md) - Flow ratio constraints
Expand Down
70 changes: 35 additions & 35 deletions docs/user-guide/mathematical-notation/features/OnOffParameters.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OnOffParameters
# ActivityParameters

[`OnOffParameters`][flixopt.interface.OnOffParameters] model equipment that operates in discrete on/off states rather than continuous operation. This captures realistic operational constraints including startup costs, minimum run times, cycling limitations, and maintenance scheduling.
[`ActivityParameters`][flixopt.interface.ActivityParameters] model equipment that operates in discrete on/off states rather than continuous operation. This captures realistic operational constraints including startup costs, minimum run times, cycling limitations, and maintenance scheduling.

## Binary State Variable

Expand Down Expand Up @@ -190,14 +190,14 @@ With:

## Integration with Flow Bounds

OnOffParameters modify flow rate bounds by coupling them to the on/off state.
ActivityParameters modify flow rate bounds by coupling them to the on/off state.

**Without OnOffParameters** (continuous operation):
**Without ActivityParameters** (continuous operation):
$$
P \cdot \text{rel}_\text{lower} \leq p(t) \leq P \cdot \text{rel}_\text{upper}
$$

**With OnOffParameters** (binary operation):
**With ActivityParameters** (binary operation):
$$
s(t) \cdot P \cdot \max(\varepsilon, \text{rel}_\text{lower}) \leq p(t) \leq s(t) \cdot P \cdot \text{rel}_\text{upper}
$$
Expand All @@ -212,7 +212,7 @@ Using the **bounds with state** pattern from [Bounds and States](../modeling-pat

## Complete Formulation Summary

For equipment with OnOffParameters, the complete constraint system includes:
For equipment with ActivityParameters, the complete constraint system includes:

1. **State variable:** $s(t) \in \{0, 1\}$
2. **Switch tracking:** $s^\text{on}(t) - s^\text{off}(t) = s(t) - s(t-1)$
Expand All @@ -232,18 +232,18 @@ For equipment with OnOffParameters, the complete constraint system includes:

## Implementation

**Python Class:** [`OnOffParameters`][flixopt.interface.OnOffParameters]
**Python Class:** [`ActivityParameters`][flixopt.interface.ActivityParameters]

**Key Parameters:**
- `effects_per_switch_on`: Costs per startup event
- `effects_per_startup`: Costs per startup event
- `effects_per_running_hour`: Costs per hour of operation
- `on_hours_total_min`, `on_hours_total_max`: Total runtime bounds
- `consecutive_on_hours_min`, `consecutive_on_hours_max`: Consecutive runtime bounds
- `consecutive_off_hours_min`, `consecutive_off_hours_max`: Consecutive shutdown bounds
- `switch_on_total_max`: Maximum number of startups
- `active_hours_total_min`, `active_hours_total_max`: Total runtime bounds
- `consecutive_active_hours_min`, `consecutive_active_hours_max`: Consecutive runtime bounds
- `consecutive_inactive_hours_min`, `consecutive_inactive_hours_max`: Consecutive shutdown bounds
- `startup_total_max`: Maximum number of startups
- `force_switch_on`: Create switch variables even without limits (for tracking)

See the [`OnOffParameters`][flixopt.interface.OnOffParameters] API documentation for complete parameter list and usage examples.
See the [`ActivityParameters`][flixopt.interface.ActivityParameters] API documentation for complete parameter list and usage examples.

**Mathematical Patterns Used:**
- [State Transitions](../modeling-patterns/state-transitions.md#binary-state-transitions) - Switch tracking
Expand All @@ -260,48 +260,48 @@ See the [`OnOffParameters`][flixopt.interface.OnOffParameters] API documentation

### Power Plant with Startup Costs
```python
power_plant = OnOffParameters(
effects_per_switch_on={'startup_cost': 25000}, # €25k per startup
power_plant = ActivityParameters(
effects_per_startup={'startup_cost': 25000}, # €25k per startup
effects_per_running_hour={'fixed_om': 125}, # €125/hour while running
consecutive_on_hours_min=8, # Minimum 8-hour run
consecutive_off_hours_min=4, # 4-hour cooling period
on_hours_total_max=6000, # Annual limit
consecutive_active_hours_min=8, # Minimum 8-hour run
consecutive_inactive_hours_min=4, # 4-hour cooling period
active_hours_total_max=6000, # Annual limit
)
```

### Batch Process with Cycling Limits
```python
batch_reactor = OnOffParameters(
effects_per_switch_on={'setup_cost': 1500},
consecutive_on_hours_min=12, # 12-hour minimum batch
consecutive_on_hours_max=24, # 24-hour maximum batch
consecutive_off_hours_min=6, # Cleaning time
switch_on_total_max=200, # Max 200 batches
batch_reactor = ActivityParameters(
effects_per_startup={'setup_cost': 1500},
consecutive_active_hours_min=12, # 12-hour minimum batch
consecutive_active_hours_max=24, # 24-hour maximum batch
consecutive_inactive_hours_min=6, # Cleaning time
startup_total_max=200, # Max 200 batches
)
```

### HVAC with Cycle Prevention
```python
hvac = OnOffParameters(
effects_per_switch_on={'compressor_wear': 0.5},
consecutive_on_hours_min=1, # Prevent short cycling
consecutive_off_hours_min=0.5, # 30-min minimum off
switch_on_total_max=2000, # Limit compressor starts
hvac = ActivityParameters(
effects_per_startup={'compressor_wear': 0.5},
consecutive_active_hours_min=1, # Prevent short cycling
consecutive_inactive_hours_min=0.5, # 30-min minimum off
startup_total_max=2000, # Limit compressor starts
)
```

### Backup Generator with Testing Requirements
```python
backup_gen = OnOffParameters(
effects_per_switch_on={'fuel_priming': 50}, # L diesel
consecutive_on_hours_min=0.5, # 30-min test duration
consecutive_off_hours_max=720, # Test every 30 days
on_hours_total_min=26, # Weekly testing requirement
backup_gen = ActivityParameters(
effects_per_startup={'fuel_priming': 50}, # L diesel
consecutive_active_hours_min=0.5, # 30-min test duration
consecutive_inactive_hours_max=720, # Test every 30 days
active_hours_total_min=26, # Weekly testing requirement
)
```

---

## Notes

**Time Series Boundary:** The final time period constraints for consecutive_on_hours_min/max and consecutive_off_hours_min/max are not enforced at the end of the planning horizon. This allows optimization to end with ongoing campaigns that may be shorter/longer than specified, as they extend beyond the modeled period.
**Time Series Boundary:** The final time period constraints for consecutive_active_hours_min/max and consecutive_inactive_hours_min/max are not enforced at the end of the planning horizon. This allows optimization to end with ongoing campaigns that may be shorter/longer than specified, as they extend beyond the modeled period.
8 changes: 4 additions & 4 deletions docs/user-guide/mathematical-notation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Mathematical formulations for core FlixOpt elements (corresponding to [`flixopt.
Mathematical formulations for optional features (corresponding to parameters in FlixOpt classes):

- [InvestParameters](features/InvestParameters.md) - Investment decision modeling
- [OnOffParameters](features/OnOffParameters.md) - Binary on/off operation
- [ActivityParameters](features/ActivityParameters.md) - Binary on/off operation
- [Piecewise](features/Piecewise.md) - Piecewise linear approximations

**User API:** When you pass `invest_parameters` or `on_off_parameters` to a `Flow` or component, these formulations are applied.
**User API:** When you pass `invest_parameters` or `activity_parameters` to a `Flow` or component, these formulations are applied.

### System-Level
- [Effects, Penalty & Objective](effects-penalty-objective.md) - Cost allocation and objective function
Expand Down Expand Up @@ -97,7 +97,7 @@ Mathematical formulations for optional features (corresponding to parameters in
| Concept | Documentation | Python Class |
|---------|---------------|--------------|
| **Binary investment** | [InvestParameters](features/InvestParameters.md) | [`InvestParameters`][flixopt.interface.InvestParameters] |
| **On/off operation** | [OnOffParameters](features/OnOffParameters.md) | [`OnOffParameters`][flixopt.interface.OnOffParameters] |
| **On/off operation** | [ActivityParameters](features/ActivityParameters.md) | [`ActivityParameters`][flixopt.interface.ActivityParameters] |
| **Piecewise segments** | [Piecewise](features/Piecewise.md) | [`Piecewise`][flixopt.interface.Piecewise] |

### Modeling Patterns Cross-Reference
Expand All @@ -119,5 +119,5 @@ Mathematical formulations for optional features (corresponding to parameters in
| `Storage` | [Storage](elements/Storage.md) | [`Storage`][flixopt.components.Storage] |
| `LinearConverter` | [LinearConverter](elements/LinearConverter.md) | [`LinearConverter`][flixopt.components.LinearConverter] |
| `InvestParameters` | [InvestParameters](features/InvestParameters.md) | [`InvestParameters`][flixopt.interface.InvestParameters] |
| `OnOffParameters` | [OnOffParameters](features/OnOffParameters.md) | [`OnOffParameters`][flixopt.interface.OnOffParameters] |
| `ActivityParameters` | [ActivityParameters](features/ActivityParameters.md) | [`ActivityParameters`][flixopt.interface.ActivityParameters] |
| `Piecewise` | [Piecewise](features/Piecewise.md) | [`Piecewise`][flixopt.interface.Piecewise] |
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ With:
**Implementation:** [`BoundingPatterns.bounds_with_state()`][flixopt.modeling.BoundingPatterns.bounds_with_state]

**Used in:**
- Flow rates with on/off operation (see [OnOffParameters](../features/OnOffParameters.md))
- Flow rates with on/off operation (see [ActivityParameters](../features/ActivityParameters.md))
- Investment size decisions (see [InvestParameters](../features/InvestParameters.md))

---
Expand Down Expand Up @@ -108,7 +108,7 @@ Where $v_\text{scale,max}$ and $v_\text{scale,min}$ are the maximum and minimum

**Used in:**
- Flow rates with on/off operation and investment sizing
- Components combining [OnOffParameters](../features/OnOffParameters.md) and [InvestParameters](../features/InvestParameters.md)
- Components combining [ActivityParameters](../features/ActivityParameters.md) and [InvestParameters](../features/InvestParameters.md)

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ maintenance_duration = modeling.consecutive_duration_tracking(
## Used In

This pattern is used in:
- [`OnOffParameters`](../features/OnOffParameters.md) - Minimum on/off times
- [`ActivityParameters`](../features/ActivityParameters.md) - Minimum on/off times
- Operating mode constraints with minimum durations
- Startup/shutdown sequence modeling
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ These patterns are used throughout FlixOpt components:

- [`Flow`][flixopt.elements.Flow] uses **scaled bounds with state** for flow rate constraints
- [`Storage`][flixopt.components.Storage] uses **basic bounds** for charge state
- [`OnOffParameters`](../features/OnOffParameters.md) uses **state transitions** for startup/shutdown
- [`ActivityParameters`](../features/ActivityParameters.md) uses **state transitions** for startup/shutdown
- [`InvestParameters`](../features/InvestParameters.md) uses **bounds with state** for investment decisions

## Implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ model.add_constraint(increase.sum() <= max_total_expansion)
## Used In

These patterns are used in:
- [`OnOffParameters`](../features/OnOffParameters.md) - Startup/shutdown tracking and costs
- [`ActivityParameters`](../features/ActivityParameters.md) - Startup/shutdown tracking and costs
- Operating mode switching with transition costs
- Investment planning with staged capacity additions
- Inventory management with controlled stock changes
Loading
Loading