Update dependencies; switch to Documenter.jl

feature/stochastic
Alinson S. Xavier 3 years ago
parent 92d30460b9
commit 19a34fb5d2
Signed by: isoron
GPG Key ID: 0DA8E4B9E1109DCA

@ -1,28 +1,19 @@
JULIA := julia --color=yes --project=@.
SRC_FILES := $(wildcard src/*.jl test/*.jl)
VERSION := 0.5 VERSION := 0.5
all: docs test
build/sysimage.so: src/sysimage.jl Project.toml Manifest.toml
mkdir -p build
$(JULIA) src/sysimage.jl
build/test.log: $(SRC_FILES) build/sysimage.so
cd test; $(JULIA) --sysimage ../build/sysimage.so runtests.jl
clean: clean:
rm -rf build/* rm -rfv build Manifest.toml test/Manifest.toml deps/formatter/build deps/formatter/Manifest.toml
docs: docs:
mkdocs build -d ../docs/$(VERSION)/ cd docs; julia --project=. make.jl; cd ..
rsync -avP --delete-after docs/build/ ../docs/$(VERSION)/
format: format:
julia -e 'using JuliaFormatter; format(["src", "test"], verbose=true);' cd deps/formatter; ../../juliaw format.jl
test: build/test.log test: test/Manifest.toml
./juliaw test/runtests.jl
test-watch: test/Manifest.toml: test/Project.toml
bash -c "while true; do make test --quiet; sleep 1; done" julia --project=test -e "using Pkg; Pkg.instantiate()"
.PHONY: docs test .PHONY: docs test format

@ -1,7 +1,7 @@
name = "RELOG" name = "RELOG"
uuid = "a2afcdf7-cf04-4913-85f9-c0d81ddf2008" uuid = "a2afcdf7-cf04-4913-85f9-c0d81ddf2008"
authors = ["Alinson S Xavier <axavier@anl.gov>"] authors = ["Alinson S Xavier <axavier@anl.gov>"]
version = "0.5.1" version = "0.5.2"
[deps] [deps]
CRC = "44b605c4-b955-5f2b-9b6d-d2bd01d3d205" CRC = "44b605c4-b955-5f2b-9b6d-d2bd01d3d205"
@ -19,7 +19,6 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProgressBars = "49802e3a-d2f1-5c88-81d8-b72133a6f568" ProgressBars = "49802e3a-d2f1-5c88-81d8-b72133a6f568"
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4" Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
@ -29,20 +28,19 @@ ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"
[compat] [compat]
CRC = "4" CRC = "4"
CSV = "0.7" CSV = "0.10"
Cbc = "0.6" Cbc = "1"
Clp = "0.8" Clp = "1"
DataFrames = "0.21" DataFrames = "1"
DataStructures = "0.17" DataStructures = "0.18"
GZip = "0.5" GZip = "0.5"
Geodesy = "0.5" Geodesy = "1"
JSON = "0.21" JSON = "0.21"
JSONSchema = "0.3" JSONSchema = "1"
JuMP = "0.21" JuMP = "1"
MathOptInterface = "0.9" MathOptInterface = "1"
OrderedCollections = "1.4" OrderedCollections = "1"
PackageCompiler = "1" ProgressBars = "1"
ProgressBars = "0.6" Shapefile = "0.8"
Shapefile = "0.7" ZipFile = "0.10"
ZipFile = "0.9"
julia = "1" julia = "1"

@ -0,0 +1,5 @@
[deps]
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
[compat]
JuliaFormatter = "0.14.4"

@ -0,0 +1,8 @@
using JuliaFormatter
format(
[
"../../src",
"../../test",
],
verbose=true,
)

@ -0,0 +1,4 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
RELOG = "a2afcdf7-cf04-4913-85f9-c0d81ddf2008"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

@ -0,0 +1,19 @@
using Documenter, RELOG
function make()
makedocs(
sitename="RELOG",
pages=[
"Home" => "index.md",
"usage.md",
"format.md",
"reports.md",
"model.md",
],
format = Documenter.HTML(
assets=["assets/custom.css"],
)
)
end
make()

@ -0,0 +1,36 @@
@media screen and (min-width: 1056px) {
#documenter .docs-main {
max-width: 65rem !important;
}
}
tbody, thead, pre {
border: 1px solid rgba(0, 0, 0, 0.25);
}
table td, th {
padding: 8px;
}
table p {
margin-bottom: 0;
}
table td code {
white-space: nowrap;
}
table tr,
table th {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
table tr:last-child {
border-bottom: 0;
}
code {
background-color: transparent;
color: rgb(232, 62, 140);
}

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Before

Width:  |  Height:  |  Size: 586 KiB

After

Width:  |  Height:  |  Size: 586 KiB

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

@ -11,7 +11,7 @@ RELOG accepts as input a JSON file with three sections: `parameters`, `products`
The **parameters** section describes details about the simulation itself. The **parameters** section describes details about the simulation itself.
| Key | Description | Key | Description
|:--------------------------|---------------| |:--------------------------|:---------------|
|`time horizon (years)` | Number of years in the simulation. |`time horizon (years)` | Number of years in the simulation.
|`building period (years)` | List of years in which we are allowed to open new plants. For example, if this parameter is set to `[1,2,3]`, we can only open plants during the first three years. By default, this equals `[1]`; that is, plants can only be opened during the first year. | |`building period (years)` | List of years in which we are allowed to open new plants. For example, if this parameter is set to `[1,2,3]`, we can only open plants during the first three years. By default, this equals `[1]`; that is, plants can only be opened during the first year. |
@ -31,7 +31,7 @@ The **parameters** section describes details about the simulation itself.
The **products** section describes all products and subproducts in the simulation. The field `instance["Products"]` is a dictionary mapping the name of the product to a dictionary which describes its characteristics. Each product description contains the following keys: The **products** section describes all products and subproducts in the simulation. The field `instance["Products"]` is a dictionary mapping the name of the product to a dictionary which describes its characteristics. Each product description contains the following keys:
| Key | Description | Key | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
|`transportation cost ($/km/tonne)` | The cost to transport this product. Must be a time series. |`transportation cost ($/km/tonne)` | The cost to transport this product. Must be a time series.
|`transportation energy (J/km/tonne)` | The energy required to transport this product. Must be a time series. Optional. |`transportation energy (J/km/tonne)` | The energy required to transport this product. Must be a time series. Optional.
|`transportation emissions (tonne/km/tonne)` | A dictionary mapping the name of each greenhouse gas, produced to transport one tonne of this product along one kilometer, to the amount of gas produced (in tonnes). Must be a time series. Optional. |`transportation emissions (tonne/km/tonne)` | A dictionary mapping the name of each greenhouse gas, produced to transport one tonne of this product along one kilometer, to the amount of gas produced (in tonnes). Must be a time series. Optional.
@ -40,7 +40,7 @@ The **products** section describes all products and subproducts in the simulatio
Each product may have some amount available at the beginning of each time period. In this case, the key `initial amounts` maps to a dictionary with the following keys: Each product may have some amount available at the beginning of each time period. In this case, the key `initial amounts` maps to a dictionary with the following keys:
| Key | Description | Key | Description
|:------------------------|---------------| |:------------------------|:---------------|
| `latitude (deg)` | The latitude of the location. | `latitude (deg)` | The latitude of the location.
| `longitude (deg)` | The longitude of the location. | `longitude (deg)` | The longitude of the location.
| `amount (tonne)` | The amount of the product initially available at the location. Must be a time series. | `amount (tonne)` | The amount of the product initially available at the location. Must be a time series.
@ -93,7 +93,7 @@ Each product may have some amount available at the beginning of each time period
The **plants** section describes the available types of reverse manufacturing plants, their potential locations and associated costs, as well as their inputs and outputs. The field `instance["Plants"]` is a dictionary mapping the name of the plant to a dictionary with the following keys: The **plants** section describes the available types of reverse manufacturing plants, their potential locations and associated costs, as well as their inputs and outputs. The field `instance["Plants"]` is a dictionary mapping the name of the plant to a dictionary with the following keys:
| Key | Description | Key | Description
|:------------------------|---------------| |:------------------------|:---------------|
| `input` | The name of the product that this plant takes as input. Only one input is accepted per plant. | `input` | The name of the product that this plant takes as input. Only one input is accepted per plant.
| `outputs (tonne/tonne)` | A dictionary specifying how many tonnes of each product is produced for each tonnes of input. For example, if the plant outputs 0.5 tonnes of P2 and 0.25 tonnes of P3 for each tonnes of P1 provided, then this entry should be `{"P2": 0.5, "P3": 0.25}`. If the plant does not output anything, this key may be omitted. | `outputs (tonne/tonne)` | A dictionary specifying how many tonnes of each product is produced for each tonnes of input. For example, if the plant outputs 0.5 tonnes of P2 and 0.25 tonnes of P3 for each tonnes of P1 provided, then this entry should be `{"P2": 0.5, "P3": 0.25}`. If the plant does not output anything, this key may be omitted.
|`energy (GJ/tonne)` | The energy required to process 1 tonne of the input. Must be a time series. Optional. |`energy (GJ/tonne)` | The energy required to process 1 tonne of the input. Must be a time series. Optional.
@ -113,14 +113,14 @@ Each type of plant is associated with a set of potential locations where it can
The `storage` dictionary should contain the following keys: The `storage` dictionary should contain the following keys:
| Key | Description | Key | Description
|:------------------------|---------------| |:------------------------|:---------------|
| `cost ($/tonne)` | The cost to store a tonne of input product for one time period. Must be a time series. | `cost ($/tonne)` | The cost to store a tonne of input product for one time period. Must be a time series.
| `limit (tonne)` | The maximum amount of input product this plant can have in storage at any given time. | `limit (tonne)` | The maximum amount of input product this plant can have in storage at any given time.
The keys in the `disposal` dictionary should be the names of the products. The values are dictionaries with the following keys: The keys in the `disposal` dictionary should be the names of the products. The values are dictionaries with the following keys:
| Key | Description | Key | Description
|:------------------------|---------------| |:------------------------|:---------------|
| `cost ($/tonne)` | The cost to dispose of the product. Must be a time series. | `cost ($/tonne)` | The cost to dispose of the product. Must be a time series.
| `limit (tonne)` | The maximum amount that can be disposed of. If an unlimited amount can be disposed, this key may be omitted. Must be a time series. | `limit (tonne)` | The maximum amount that can be disposed of. If an unlimited amount can be disposed, this key may be omitted. Must be a time series.
@ -128,7 +128,7 @@ The keys in the `disposal` dictionary should be the names of the products. The v
The keys in the `capacities (tonne)` dictionary should be the amounts (in tonnes). The values are dictionaries with the following keys: The keys in the `capacities (tonne)` dictionary should be the amounts (in tonnes). The values are dictionaries with the following keys:
| Key | Description | Key | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `opening cost ($)` | The cost to open a plant of this size. | `opening cost ($)` | The cost to open a plant of this size.
| `fixed operating cost ($)` | The cost to keep the plant open, even if the plant doesn't process anything. Must be a time series. | `fixed operating cost ($)` | The cost to keep the plant open, even if the plant doesn't process anything. Must be a time series.
| `variable operating cost ($/tonne)` | The cost that the plant incurs to process each tonne of input. Must be a time series. | `variable operating cost ($/tonne)` | The cost that the plant incurs to process each tonne of input. Must be a time series.
@ -210,7 +210,7 @@ is is possible to write:
Location names follow the format `db:id`, where `db` is the name of the database and `id` is the identifier for a specific location. RELOG currently includes the following databases: Location names follow the format `db:id`, where `db` is the name of the database and `id` is the identifier for a specific location. RELOG currently includes the following databases:
Database | Description | Examples Database | Description | Examples
---------|-------------|---------- :--------|:------------|:---------
`us-state`| List of states of the United States. | `us-state:IL` (State of Illinois) `us-state`| List of states of the United States. | `us-state:IL` (State of Illinois)
`2018-us-county` | List of United States counties, as of 2018. IDs are 5-digit FIPS codes. | `2018-us-county:17043` (DuPage county in Illinois) `2018-us-county` | List of United States counties, as of 2018. IDs are 5-digit FIPS codes. | `2018-us-county:17043` (DuPage county in Illinois)

@ -1,25 +1,29 @@
# RELOG: Reverse Logistics Optimization # RELOG: Reverse Logistics Optimization
**RELOG** is an open-source supply chain optimization package focusing on reverse logistics and reverse manufacturing. The package uses Mixed-Integer Linear Programming to determine where to build recycling plants, what size should these plants have and which customers should be served by which plants. The package supports custom reverse logistics pipelines, with multiple types of plants, multiple types of product and multiple time periods. **RELOG** is an open-source supply chain optimization package focusing on reverse logistics and reverse manufacturing. The package uses Mixed-Integer Linear Programming to determine where to build recycling plants, what size should these plants have and which customers should be served by which plants. The package supports custom reverse logistics pipelines, with multiple types of plants, multiple types of product and multiple time periods.
<img src="images/ex_transportation.png" width="1000px"/> ```@raw html
<center>
<img src="../assets/ex_transportation.png" width="1000px"/>
</center>
```
### Table of Contents ### Table of Contents
* [Usage](usage.md) ```@contents
* [Input and Output Data Formats](format.md) Pages = ["usage.md", "format.md", "reports.md", "model.md"]
* [Simplified Solution Reports](reports.md) Depth = 3
* [Optimization Model](model.md) ```
### Source Code ### Source Code
* [https://github.com/ANL-CEEESA/RELOG](https://github.com/ANL-CEEESA/RELOG) * [https://github.com/ANL-CEEESA/RELOG](https://github.com/ANL-CEEESA/RELOG)
### Authors ### Authors
* **Alinson S. Xavier,** Argonne National Laboratory <<axavier@anl.gov>> * **Alinson S. Xavier,** Argonne National Laboratory <axavier@anl.gov>
* **Nwike Iloeje,** Argonne National Laboratory <<ciloeje@anl.gov>> * **Nwike Iloeje,** Argonne National Laboratory <ciloeje@anl.gov>
### License ### License

@ -6,53 +6,65 @@ In this page, we describe the precise mathematical optimization model used by RE
### Sets ### Sets
* $L$ - Set of locations holding the original material to be recycled Symbol | Description
* $M$ - Set of materials recovered during the reverse manufacturing process :-------|:------------
* $P$ - Set of potential plants to open $L$ | Set of locations holding the original material to be recycled
* $T = \{ 1, \ldots, t^{max} \} $ - Set of time periods $M$ | Set of materials recovered during the reverse manufacturing process
$P$ | Set of potential plants to open
$T = \{ 1, \ldots, t^{max} \}$ | Set of time periods
### Constants ### Constants
**Plants:** #### Plants
* $c^\text{disp}_{pmt}$ - Cost of disposing one tonne of material $m$ at plant $p$ during time $t$ (`$/tonne/km`) Symbol | Description | Unit
* $c^\text{exp}_{pt}$ - Cost of adding one tonne of capacity to plant $p$ at time $t$ (`$/tonne`) :-------|:------------|:---
* $c^\text{open}_{pt}$ - Cost of opening plant $p$ at time $t$, at minimum capacity (`$`) $c^\text{disp}_{pmt}$ | Cost of disposing one tonne of material $m$ at plant $p$ during time $t$ | \$/tonne/km
* $c^\text{f-base}_{pt}$ - Fixed cost of keeping plant $p$ open during time period $t$ (`$`) $c^\text{exp}_{pt}$ | Cost of adding one tonne of capacity to plant $p$ at time $t$ | \$/tonne
* $c^\text{f-exp}_{pt}$ - Increase in fixed cost for each additional tonne of capacity (`$/tonne`) $c^\text{open}_{pt}$ | Cost of opening plant $p$ at time $t$, at minimum capacity | $
* $c^\text{var}_{pt}$ - Variable cost of processing one tonne of input at plant $p$ at time $t$ (`$/tonne`) $c^\text{f-base}_{pt}$ | Fixed cost of keeping plant $p$ open during time period $t$ | $
* $c^\text{store}_{pt}$ - Cost of storing one tonne of original material at plant $p$ at time $t$ (`$/tonne`) $c^\text{f-exp}_{pt}$ | Increase in fixed cost for each additional tonne of capacity | \$/tonne
* $m^\text{min}_p$ - Minimum capacity of plant $p$ (`tonne`) $c^\text{var}_{pt}$ | Variable cost of processing one tonne of input at plant $p$ at time $t$ | \$/tonne
* $m^\text{max}_p$ - Maximum capacity of plant $p$ (`tonne`) $c^\text{store}_{pt}$ | Cost of storing one tonne of original material at plant $p$ at time $t$ | \$/tonne
* $m^\text{disp}_{pmt}$ - Maximum amount of material $m$ that plant $p$ can dispose of during time $t$ (`tonne`) $m^\text{min}_p$ | Minimum capacity of plant $p$ | tonne
* $m^\text{store}_p$ - Maximum amount of original material that plant $p$ can store for later processing. $m^\text{max}_p$ | Maximum capacity of plant $p$ | tonne
$m^\text{disp}_{pmt}$ | Maximum amount of material $m$ that plant $p$ can dispose of during time $t$ | tonne
$m^\text{store}_p$ | Maximum amount of original material that plant $p$ can store for later processing. | tonne
**Products:** #### Products
* $\alpha_{pm}$ - Amount of material $m$ recovered by plant $t$ for each tonne of original material (`tonne/tonne`) Symbol | Description | Unit
* $m^\text{initial}_{lt}$ - Amount of original material to be recycled at location $l$ during time $t$ (`tonne`) :-------|:------------|:---
$\alpha_{pm}$ | Amount of material $m$ recovered by plant $t$ for each tonne of original material | tonne/tonne
$m^\text{initial}_{lt}$ | Amount of original material to be recycled at location $l$ during time $t$ | tonne
**Transportation:** #### Transportation
* $c^\text{tr}_{t}$ - Transportation cost during time $t$ (`$/tonne/km`) Symbol | Description | Unit
* $d_{lp}$ - Distance between plant $p$ and location $l$ (`km`) :-------|:------------|:---
$c^\text{tr}_{t}$ | Transportation cost during time $t$ | \$/tonne/km
$d_{lp}$ | Distance between plant $p$ and location $l$ | km
### Decision variables ### Decision variables
* $q_{mpt}$ - Amount of material $m$ recovered by plant $p$ during time $t$ (`tonne`)
* $u_{pt}$ - Binary variable that equals 1 if plant $p$ starts operating at time $t$ (`bool`) Symbol | Description | Unit
* $w_{pt}$ - Extra capacity (amount above the minimum) added to plant $p$ during time $t$ (`tonne`) :-------|:------------|:---
* $x_{pt}$ - Binary variable that equals 1 if plant $p$ is operational at time $t$ (`bool`) $q_{mpt}$ | Amount of material $m$ recovered by plant $p$ during time $t$ | tonne
* $y_{lpt}$ - Amount of product sent from location $l$ to plant $p$ during time $t$ (`tonne`) $u_{pt}$ | Binary variable that equals 1 if plant $p$ starts operating at time $t$ | Boolean
* $z^{\text{disp}}_{mpt}$ - Amount of material $m$ disposed of by plant $p$ during time $t$ (`tonne`) $w_{pt}$ | Extra capacity (amount above the minimum) added to plant $p$ during time $t$ | tonne
* $z^{\text{store}}_{pt}$ - Amount of original material in storage at plant $p$ by the end of time period $t$ (`tonne`) $x_{pt}$ | Binary variable that equals 1 if plant $p$ is operational at time $t$ | Boolean
* $z^{\text{proc}}_{mpt}$ - Amount of original material processed by plant $p$ during time period $t$ (`tonne`) $y_{lpt}$ | Amount of product sent from location $l$ to plant $p$ during time $t$ | tonne
$z^{\text{disp}}_{mpt}$ | Amount of material $m$ disposed of by plant $p$ during time $t$ | tonne
$z^{\text{store}}_{pt}$ | Amount of original material in storage at plant $p$ by the end of time period $t$ | tonne
$z^{\text{proc}}_{mpt}$ | Amount of original material processed by plant $p$ during time period $t$ | tonne
### Objective function ### Objective function
RELOG minimizes the overall capital, production and transportation costs: RELOG minimizes the overall capital, production and transportation costs:
```math
\begin{align*} \begin{align*}
\text{minimize} \;\; & \text{minimize} \;\; &
\sum_{t \in T} \sum_{p \in P} \left[ \sum_{t \in T} \sum_{p \in P} \left[
@ -73,6 +85,7 @@ RELOG minimizes the overall capital, production and transportation costs:
& &
\sum_{t \in T} \sum_{p \in P} \sum_{m \in M} c^{\text{disp}}_{pmt} z_{pmt} \sum_{t \in T} \sum_{p \in P} \sum_{m \in M} c^{\text{disp}}_{pmt} z_{pmt}
\end{align*} \end{align*}
```
In the first line, we have (i) opening costs, if plant starts operating at time $t$, (ii) fixed operating costs, if plant is operational, (iii) additional fixed operating costs coming from expansion performed in all previous time periods up to the current one, and finally (iv) the expansion costs during the current time period. In the first line, we have (i) opening costs, if plant starts operating at time $t$, (ii) fixed operating costs, if plant is operational, (iii) additional fixed operating costs coming from expansion performed in all previous time periods up to the current one, and finally (iv) the expansion costs during the current time period.
In the second line, we have storage and variable processing costs. In the second line, we have storage and variable processing costs.
@ -83,14 +96,17 @@ In the fourth line, we have the disposal costs.
* All original materials must be sent to a plant: * All original materials must be sent to a plant:
\begin{align} ```math
\begin{align*}
& \sum_{p \in P} y_{lpt} = m^\text{initial}_{lt} & \sum_{p \in P} y_{lpt} = m^\text{initial}_{lt}
& \forall l \in L, t \in T & \forall l \in L, t \in T
\end{align} \end{align*}
```
* Amount received equals amount processed plus stored. Furthermore, all original material should be processed by the end of the simulation. * Amount received equals amount processed plus stored. Furthermore, all original material should be processed by the end of the simulation.
\begin{align} ```math
\begin{align*}
& \sum_{l \in L} y_{lpt} + z^{\text{store}}_{p,t-1} & \sum_{l \in L} y_{lpt} + z^{\text{store}}_{p,t-1}
= z^{\text{proc}}_{pt} + z^{\text{store}}_{p,t} = z^{\text{proc}}_{pt} + z^{\text{store}}_{p,t}
& \forall p \in P, t \in T \\ & \forall p \in P, t \in T \\
@ -98,56 +114,70 @@ In the fourth line, we have the disposal costs.
& \forall p \in P \\ & \forall p \in P \\
& z^{\text{store}}_{p,t^{\max}} = 0 & z^{\text{store}}_{p,t^{\max}} = 0
& \forall p \in P & \forall p \in P
\end{align} \end{align*}
```
* Plants have a limited processing capacity. Furthermore, if a plant is closed, it has zero processing capacity: * Plants have a limited processing capacity. Furthermore, if a plant is closed, it has zero processing capacity:
\begin{align} ```math
\begin{align*}
& z^{\text{proc}}_{pt} \leq m^\text{min}_p x_p + \sum_{i=1}^t w_p & z^{\text{proc}}_{pt} \leq m^\text{min}_p x_p + \sum_{i=1}^t w_p
& \forall p \in P, t \in T & \forall p \in P, t \in T
\end{align} \end{align*}
```
* Plants have limited storage capacity. Furthermore, if a plant is closed, is has zero storage capacity: * Plants have limited storage capacity. Furthermore, if a plant is closed, is has zero storage capacity:
\begin{align} ```math
\begin{align*}
& z^{\text{store}}_{pt} \leq m^\text{store}_p x_p & z^{\text{store}}_{pt} \leq m^\text{store}_p x_p
& \forall p \in P, t \in T & \forall p \in P, t \in T
\end{align} \end{align*}
```
* Plants can only be expanded up to their maximum capacity. Furthermore, if a plant is closed, it cannot be expanded: * Plants can only be expanded up to their maximum capacity. Furthermore, if a plant is closed, it cannot be expanded:
\begin{align} ```math
\begin{align*}
& \sum_{i=1}^t w_p \leq m^\text{max}_p x_p & \sum_{i=1}^t w_p \leq m^\text{max}_p x_p
& \forall p \in P, t \in T & \forall p \in P, t \in T
\end{align} \end{align*}
```
* Amount of recovered material is proportional to amount processed: * Amount of recovered material is proportional to amount processed:
\begin{align} ```math
\begin{align*}
& q_{mpt} = \alpha_{pm} z^{\text{proc}}_{pt} & q_{mpt} = \alpha_{pm} z^{\text{proc}}_{pt}
& \forall m \in M, p \in P, t \in T & \forall m \in M, p \in P, t \in T
\end{align} \end{align*}
```
* Because we only consider a single type of plant, all recovered material must be immediately disposed of. In RELOG's full model, recovered materials may be sent to another plant for further processing. * Because we only consider a single type of plant, all recovered material must be immediately disposed of. In RELOG's full model, recovered materials may be sent to another plant for further processing.
\begin{align} ```math
\begin{align*}
& q_{mpt} = z_{mpt} & q_{mpt} = z_{mpt}
& \forall m \in M, p \in P, t \in T & \forall m \in M, p \in P, t \in T
\end{align} \end{align*}
```
* A plant is operational at time $t$ if it was operational at time $t-1$ or it was built at time $t$. This constraint also prevents a plant from being built multiple times. * A plant is operational at time $t$ if it was operational at time $t-1$ or it was built at time $t$. This constraint also prevents a plant from being built multiple times.
\begin{align} ```math
\begin{align*}
& x_{pt} = x_{p,t-1} + u_{pt} & x_{pt} = x_{p,t-1} + u_{pt}
& \forall p \in P, t \in T \setminus \{1\} \\ & \forall p \in P, t \in T \setminus \{1\} \\
& x_{p,1} = u_{p,1} & x_{p,1} = u_{p,1}
& \forall p \in P & \forall p \in P
\end{align} \end{align*}
```
* Variable bounds: * Variable bounds:
\begin{align} ```math
\begin{align*}
& q_{mpt} \geq 0 & q_{mpt} \geq 0
& \forall m \in M, p \in P, t \in T \\ & \forall m \in M, p \in P, t \in T \\
& u_{pt} \in \{0,1\} & u_{pt} \in \{0,1\}
@ -162,4 +192,5 @@ In the fourth line, we have the disposal costs.
& p \in P, t \in T \\ & p \in P, t \in T \\
& z^{\text{disp}}_{mpt}, z^{\text{proc}}_{mpt} \geq 0 & z^{\text{disp}}_{mpt}, z^{\text{proc}}_{mpt} \geq 0
& \forall m \in M, p \in P, t \in T & \forall m \in M, p \in P, t \in T
\end{align} \end{align*}
```

@ -9,7 +9,7 @@ In this page, we also illustrate what types of charts and visualizations can be
Report showing plant costs, capacities, energy expenditure and utilization factors. Generated by `RELOG.write_plants_report(solution, filename)`. Report showing plant costs, capacities, energy expenditure and utilization factors. Generated by `RELOG.write_plants_report(solution, filename)`.
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `plant type` | Plant type. | `plant type` | Plant type.
| `location name` | Location name. | `location name` | Location name.
| `year` | What year this row corresponds to. This reports includes one row for each year. | `year` | What year this row corresponds to. This reports includes one row for each year.
@ -45,7 +45,9 @@ sns.barplot(x="year",
.reset_index()); .reset_index());
``` ```
<img src="../images/ex_plant_cost_per_year.png" width="500px"/> ```@raw html
<img src="../assets/ex_plant_cost_per_year.png" width="500px"/>
```
* Map showing plant locations (in Python): * Map showing plant locations (in Python):
```python ```python
@ -65,8 +67,9 @@ points = gp.points_from_xy(data["longitude (deg)"],
gp.GeoDataFrame(data, geometry=points).plot(ax=ax); gp.GeoDataFrame(data, geometry=points).plot(ax=ax);
``` ```
<img src="../images/ex_plant_locations.png" width="1000px"/> ```@raw html
<img src="../assets/ex_plant_locations.png" width="1000px"/>
```
## Plant outputs report ## Plant outputs report
@ -74,7 +77,7 @@ Report showing amount of products produced, sent and disposed of by each plant,
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `plant type` | Plant type. | `plant type` | Plant type.
| `location name` | Location name. | `location name` | Location name.
| `year` | What year this row corresponds to. This reports includes one row for each year. | `year` | What year this row corresponds to. This reports includes one row for each year.
@ -101,7 +104,9 @@ sns.barplot(x="amount produced (tonne)",
.reset_index()); .reset_index());
``` ```
<img src="../images/ex_amount_produced.png" width="500px"/> ```@raw html
<img src="../assets/ex_amount_produced.png" width="500px"/>
```
## Plant emissions report ## Plant emissions report
@ -109,7 +114,7 @@ sns.barplot(x="amount produced (tonne)",
Report showing amount of emissions produced by each plant. Generated by `RELOG.write_plant_emissions_report(solution, filename)`. Report showing amount of emissions produced by each plant. Generated by `RELOG.write_plant_emissions_report(solution, filename)`.
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `plant type` | Plant type. | `plant type` | Plant type.
| `location name` | Location name. | `location name` | Location name.
| `year` | Year. | `year` | Year.
@ -133,14 +138,16 @@ sns.barplot(x="plant type",
.reset_index()); .reset_index());
``` ```
<img src="../images/ex_emissions.png" width="500px"/> ```@raw html
<img src="../assets/ex_emissions.png" width="500px"/>
```
## Products report ## Products report
Report showing primary product amounts, locations and marginal costs. Generated by `RELOG.write_products_report(solution, filename)`. Report showing primary product amounts, locations and marginal costs. Generated by `RELOG.write_products_report(solution, filename)`.
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `product name` | Product name. | `product name` | Product name.
| `location name` | Name of the collection center. | `location name` | Name of the collection center.
| `latitude (deg)` | Latitude of the collection center. | `latitude (deg)` | Latitude of the collection center.
@ -156,7 +163,7 @@ Report showing amount of product sent from initial locations to plants, and from
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `source type` | If product is being shipped from an initial location, equals `Origin`. If product is being shipped from a plant, equals plant type. | `source type` | If product is being shipped from an initial location, equals `Origin`. If product is being shipped from a plant, equals plant type.
| `source location name` | Name of the location where the product is being shipped from. | `source location name` | Name of the location where the product is being shipped from.
| `source latitude (deg)` | Latitude of the source location. | `source latitude (deg)` | Latitude of the source location.
@ -190,7 +197,9 @@ sns.barplot(x="product",
.reset_index()); .reset_index());
``` ```
<img src="../images/ex_transportation_amount_distance.png" width="500px"/> ```@raw html
<img src="../assets/ex_transportation_amount_distance.png" width="500px"/>
```
* Map of transportation lines (in Python): * Map of transportation lines (in Python):
@ -233,7 +242,9 @@ gp.GeoDataFrame(data, geometry=points).plot(ax=ax,
markersize=50); markersize=50);
``` ```
<img src="../images/ex_transportation.png" width="1000px"/> ```@raw html
<img src="../assets/ex_transportation.png" width="1000px"/>
```
## Transportation emissions report ## Transportation emissions report
@ -241,7 +252,7 @@ gp.GeoDataFrame(data, geometry=points).plot(ax=ax,
Report showing emissions for each trip between initial locations and plants, and between pairs of plants. Generated by `RELOG.write_transportation_emissions_report(solution, filename)`. Report showing emissions for each trip between initial locations and plants, and between pairs of plants. Generated by `RELOG.write_transportation_emissions_report(solution, filename)`.
| Column | Description | Column | Description
|:--------------------------------------|---------------| |:--------------------------------------|:---------------|
| `source type` | If product is being shipped from an initial location, equals `Origin`. If product is being shipped from a plant, equals plant type. | `source type` | If product is being shipped from an initial location, equals `Origin`. If product is being shipped from a plant, equals plant type.
| `source location name` | Name of the location where the product is being shipped from. | `source location name` | Name of the location where the product is being shipped from.
| `source latitude (deg)` | Latitude of the source location. | `source latitude (deg)` | Latitude of the source location.
@ -275,4 +286,6 @@ sns.barplot(x="emission type",
.reset_index()); .reset_index());
``` ```
<img src="../images/ex_transportation_emissions.png" width="500px"/> ```@raw html
<img src="../assets/ex_transportation_emissions.png" width="500px"/>
```

@ -3,22 +3,17 @@ Usage
## 1. Installation ## 1. Installation
To use RELOG, the first step is to install the [Julia programming language](https://julialang.org/) on your machine. Note that RELOG was developed and tested with Julia 1.5 and may not be compatible with newer versions. After Julia is installed, launch the Julia console, type `]` to switch to package manger mode, then run: To use RELOG, the first step is to install the [Julia programming language](https://julialang.org/) on your machine. Note that RELOG was developed and tested with Julia 1.8 and may not be compatible with newer versions. After Julia is installed, launch the Julia console, then run:
```text ```julia
(@v1.5) pkg> add https://github.com/ANL-CEEESA/RELOG.git using Pkg
Pkg.add(name="RELOG", version="0.5")
``` ```
After the package and all its dependencies have been installed, please run the RELOG test suite, as shown below, to make sure that the package has been correctly installed: After the package and all its dependencies have been installed, please run the RELOG test suite, as shown below, to make sure that the package has been correctly installed:
```text ```julia
(@v1.5) pkg> test RELOG Pkg.test("RELOG")
```
To update the package to a newer version, type `]` to enter the package manager mode, then run:
```text
(@v1.5) pkg> update RELOG
``` ```
## 2. Modeling the problem ## 2. Modeling the problem
@ -111,13 +106,17 @@ By default, RELOG internally uses [Cbc](https://github.com/coin-or/Cbc), an open
```julia ```julia
using RELOG, Gurobi, JuMP using RELOG, Gurobi, JuMP
gurobi = optimizer_with_attributes(Gurobi.Optimizer, gurobi = optimizer_with_attributes(
"TimeLimit" => 3600, Gurobi.Optimizer,
"MIPGap" => 0.001) "TimeLimit" => 3600,
"MIPGap" => 0.001,
RELOG.solve("instance.json", )
output="solution.json",
optimizer=gurobi) RELOG.solve(
"instance.json",
output="solution.json",
optimizer=gurobi,
)
``` ```
### 5.2 Multi-period heuristics ### 5.2 Multi-period heuristics
@ -133,6 +132,8 @@ To solve an instance using this heuristic, use the option `heuristic=true`, as s
```julia ```julia
using RELOG using RELOG
solution = RELOG.solve("/home/user/instance.json", solution = RELOG.solve(
heuristic=true) "/home/user/instance.json",
heuristic=true,
)
``` ```

@ -0,0 +1,75 @@
#!/bin/bash
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
if [ ! -e Project.toml ]; then
echo "juliaw: Project.toml not found"
exit 1
fi
if [ ! -e Manifest.toml ]; then
julia --project=. -e 'using Pkg; Pkg.instantiate()' || exit 1
fi
if [ ! -e build/sysimage.so -o Project.toml -nt build/sysimage.so ]; then
echo "juliaw: rebuilding system image..."
# Generate temporary project folder
rm -rf $HOME/.juliaw
mkdir -p $HOME/.juliaw/src
cp Project.toml Manifest.toml $HOME/.juliaw
NAME=$(julia -e 'using TOML; toml = TOML.parsefile("Project.toml"); "name" in keys(toml) && print(toml["name"])')
if [ ! -z $NAME ]; then
cat > $HOME/.juliaw/src/$NAME.jl << EOF
module $NAME
end
EOF
fi
# Add PackageCompiler dependencies to temporary project
julia --project=$HOME/.juliaw -e 'using Pkg; Pkg.add(["PackageCompiler", "TOML", "Logging"])'
# Generate system image scripts
cat > $HOME/.juliaw/sysimage.jl << EOF
using PackageCompiler
using TOML
using Logging
Logging.disable_logging(Logging.Info)
mkpath("$PWD/build")
println("juliaw: generating precompilation statements...")
run(\`julia --project="$PWD" --trace-compile="$PWD"/build/precompile.jl \$(ARGS)\`)
println("juliaw: finding dependencies...")
project = TOML.parsefile("Project.toml")
manifest = TOML.parsefile("Manifest.toml")
deps = Symbol[]
for dep in keys(project["deps"])
if dep in keys(manifest)
# Up to Julia 1.6
dep_entry = manifest[dep][1]
else
# Julia 1.7+
dep_entry = manifest["deps"][dep][1]
end
if "path" in keys(dep_entry)
println(" - \$(dep) [skip]")
else
println(" - \$(dep)")
push!(deps, Symbol(dep))
end
end
println("juliaw: building system image...")
create_sysimage(
deps,
precompile_statements_file = "$PWD/build/precompile.jl",
sysimage_path = "$PWD/build/sysimage.so",
)
EOF
julia --project=$HOME/.juliaw $HOME/.juliaw/sysimage.jl $*
else
julia --project=. --sysimage build/sysimage.so $*
fi

@ -1,28 +0,0 @@
.navbar-default {
border-bottom: 0px;
background-color: #fff;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
}
a, .navbar-default a {
color: #06a !important;
font-weight: normal;
}
.disabled > a {
color: #999 !important;
}
.navbar-default a:hover,
.navbar-default .active,
.active > a {
background-color: #f0f0f0 !important;
}
.icon-bar {
background-color: #666 !important;
}
.navbar-collapse {
border-color: #fff !important;
}

@ -1,8 +0,0 @@
MathJax.Hub.Config({
"tex2jax": { inlineMath: [ [ '$', '$' ] ] }
});
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
jax: ["input/TeX", "output/HTML-CSS", "output/NativeMML"],
extensions: ["MathMenu.js", "MathZoom.js"]
});

@ -7,7 +7,7 @@ using Geodesy
function calculate_distance(source_lat, source_lon, dest_lat, dest_lon)::Float64 function calculate_distance(source_lat, source_lon, dest_lat, dest_lon)::Float64
x = LLA(source_lat, source_lon, 0.0) x = LLA(source_lat, source_lon, 0.0)
y = LLA(dest_lat, dest_lon, 0.0) y = LLA(dest_lat, dest_lon, 0.0)
return round(distance(x, y) / 1000.0, digits = 2) return round(euclidean_distance(x, y) / 1000.0, digits = 2)
end end
function build_graph(instance::Instance)::Graph function build_graph(instance::Instance)::Graph

Loading…
Cancel
Save