Skip to content

Commit

Permalink
Release 1.3.0 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ADGEfficiency authored Feb 25, 2024
1 parent f76fb03 commit 2375f8e
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test: setup-test test-docs
create-test-docs: setup-test clean-test-docs
mkdir -p ./tests/phmdoctest
python -m phmdoctest README.md --outfile tests/phmdoctest/test_readme.py
python -m phmdoctest ./docs/docs/changelog.md --outfile tests/phmdoctest/test_changelog.md
python -m phmdoctest ./docs/docs/how-to/complex-terms.md --outfile tests/phmdoctest/test_complex_terms.py
python -m phmdoctest ./docs/docs/how-to/custom-objectives.md --outfile tests/phmdoctest/test_custom_objectives.py
python -m phmdoctest ./docs/docs/validation/battery.md --outfile tests/phmdoctest/test_validate_battery.py
Expand Down
123 changes: 121 additions & 2 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,134 @@
# Changelog

## [1.3.0 - Unreleased]()
## [1.3.0](https://github.com/ADGEfficiency/energy-py-linear/releases/tag/v1.3.1)

### Different Battery Charge and Discharge Rates

### Minimum and Maximum Objective Function Terms
It's now possible to define a different charge and discharge rate in the `epl.Battery` asset.

The example below defines a maximum charge and discharge rate of `2.0`:

```python
epl.Battery(power_mw=2.0)
```

The example below defines a maximum charge rate of `2.0` with a maximum discharge rate of `1.0`:

```python
epl.Battery(power_mw=2.0, discharge_power_mw=1.0)
```

### Complex Objective Function Terms

A complex custom objective term allows you to construct an objective function with a complex set of costs and revenues.

For example, we can define an objective function that includes a cost for the maximum import above a threshold of `40`:

```python
{
"function": "max_many_variables",
"variables": {
"asset_type": "site",
"variable": "import_power_mwh",
},
"constant": 40,
"coefficient": 200,
"M": max(electric_load_mwh) * 10
}
```

See [Complex Objective Function Terms](https://energypylinear.adgefficiency.com/latest/how-to/complex-terms) in the documentation for more examples.

### Custom Accounts

To accommodate complex custom objective functions, we have added the ability to include these custom costs and revenues as a custom account:

```python
import energypylinear as epl

chp_size = 50
electric_efficiency = 0.5
electric_load_mwh = 0
electricity_prices = np.array([-1000, -750, -250, -100, 0, 10, 100, 1000])
export_charge = -500
export_threshold_mwh = 5
gas_prices = 20

assets = [
epl.CHP(
electric_efficiency_pct=electric_efficiency,
electric_power_max_mw=chp_size,
)
]
site = epl.Site(
assets=assets,
gas_prices=20,
electricity_prices=np.array([-1000, -750, -250, -100, 0, 10, 100, 1000]),
electric_load_mwh=electric_load_mwh,
)

terms: list[dict] = [
{
"asset_type": "site",
"variable": "export_power_mwh",
"interval_data": "electricity_prices",
"coefficient": -1,
},
{
"asset_type": "*",
"variable": "gas_consumption_mwh",
"interval_data": "gas_prices",
},
{
"type": "complex",
"function": "min_two_variables",
"a": {
"asset_type": "site",
"variable": "export_power_mwh",
},
"b": 5.0,
"coefficient": export_charge,
"M": (
electric_load_mwh
+ assets[0].cfg.electric_power_max_mw
+ export_threshold_mwh
)
* 1,
},
]

simulation = site.optimize(
verbose=4,
objective={"terms": terms},
)

accounts = epl.get_accounts(simulation.results, custom_terms=terms[-1:])
print(accouts.custom)
```

```
<Account profit=15000.00 emissions=0.0000>
```

### Optimization Status

The objective function value has been added to the `epl.optimizer.OptimizationStatus` object:

```python
import energypylinear as epl

site = epl.Site(
assets=[epl.Battery()],
electricity_prices=np.array([-1000, -750, -250, -100, 0, 10, 100, 1000]),
)
simulation = site.optimize(verbose=4, objective="price")
print(simulation.status)
```

```
OptimizationStatus(status='Optimal', feasible=True, objective=-5811.11111)
```

## [1.2.0](https://github.com/ADGEfficiency/energy-py-linear/releases/tag/v1.2.0)

### Custom Objective Functions
Expand Down
10 changes: 3 additions & 7 deletions docs/docs/how-to/custom-objectives.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
`energypylinear` has two different objective functions (price or carbon) built into the library.
In linear programming, the objective function defines the incentives and costs you want to optimize for.

An objective function determines the incentives and costs in a linear program. It's what you are trying to optimize for.

`energypylinear` has two different objective functions (price or carbon) built into the library.

However you may want to optimize for a different objective function in the linear program. You may have a business problem with a different set of revenues and costs than are included by default.
`energypylinear` has two different objective functions (price or carbon) built into the library. In addition, `energypylinear` allows you to define your own, custom objective function.

**A custom objective function allows you to construct an objective function that can optimize for the revenues and costs that are important to you**.

## Simple Objective Function Terms

Core to the custom objective function is the `epl.Term` - representing a single term in the objective function:
Core to the custom objective function is the `epl.Term`, which represents a single term in the objective function:

<!--phmdoctest-mark.skip-->
```python
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "energypylinear"
version = "1.2.0"
version = "1.3.0"
description = "Optimizing energy assets with mixed-integer linear programming."
authors = ["Adam Green <adam.green@adgefficiency.com>"]
license = "MIT"
Expand Down

0 comments on commit 2375f8e

Please sign in to comment.