-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
14,954 additions
and
3,812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: lint/style-and-typos | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Black Formatting Check | ||
uses: psf/black@stable | ||
with: | ||
options: "-S -C --check --diff" | ||
- name: Spell Check | ||
uses: crate-ci/typos@master | ||
with: | ||
config: ./.github/workflows/typos.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[default.extend-words] | ||
# Ignore HDA | ||
hda = "hda" | ||
HDA = "HDA" | ||
equil = "equil" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,5 @@ dmypy.json | |
|
||
# Pycharm | ||
.idea/ | ||
|
||
gdplib/*/benchmark_result/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
cff-version: 1.0.0 | ||
message: "If you use this software, please cite it as below." | ||
authors: | ||
- family-names: Bernal Neira | ||
given-names: David E. | ||
orcid: https://orcid.org/0000-0002-8308-5016 | ||
- family-names: Peng | ||
given-names: Zedong | ||
orcid: https://orcid.org/0000-0001-6001-1738 | ||
- family-names: Chen | ||
given-names: Qi | ||
orcid: https://orcid.org/0000-0002-2389-2238 | ||
- family-names: Liu | ||
given-names: Yunshan | ||
- family-names: Johnson | ||
given-names: Emma | ||
orcid: https://orcid.org/0000-0002-4285-5184 | ||
title: "GDPLib: an open library of Generalized Disjunctive Programming (GDP) models" | ||
version: 1.0.0 | ||
url: https://github.com/SECQUOIA/gdplib | ||
license-url: https://github.com/SECQUOIA/gdplib/blob/master/LICENSE | ||
preferred-citation: | ||
type: incollection | ||
booktitle: "Computer Aided Chemical Engineering" | ||
volume: 49 | ||
start: 1285 | ||
end: 1290 | ||
title: "Advances in Generalized Disjunctive and Mixed-Integer Nonlinear Programming Algorithms and Software for Superstructure Optimization" | ||
year:2022 | ||
publisher: "Elsevier" | ||
authors: | ||
- family-names: "Bernal Neira" | ||
given-names: "David E." | ||
- family-names: "Liu" | ||
given-names: "Yunshan" | ||
- family-names: "Bynum" | ||
given-names: "Michael L" | ||
- family-names: "Laird" | ||
given-names: "Carl D" | ||
- family-names: "Siirola" | ||
given-names: "John D" | ||
- family-names: "Grossmann" | ||
given-names: "Ignacio E" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import os | ||
import json | ||
import time | ||
import sys | ||
from datetime import datetime | ||
from importlib import import_module | ||
from pyomo.environ import * | ||
|
||
|
||
def benchmark(model, strategy, timelimit, result_dir, subsolver="scip"): | ||
"""Benchmark the model using the given strategy and subsolver. | ||
The result files include the solver output and the JSON representation of the results. | ||
Parameters | ||
---------- | ||
model : PyomoModel | ||
the model to be solved | ||
strategy : string | ||
the strategy used to solve the model | ||
timelimit : int | ||
the time limit for the solver | ||
result_dir : string | ||
the directory to store the benchmark results | ||
Returns | ||
------- | ||
None | ||
""" | ||
model = model.clone() | ||
stdout = sys.stdout | ||
if strategy in ["gdp.bigm", "gdp.hull"]: | ||
transformation_start_time = time.time() | ||
TransformationFactory(strategy).apply_to(model) | ||
transformation_end_time = time.time() | ||
with open( | ||
result_dir + "/" + strategy + "_" + subsolver + ".log", "w" | ||
) as sys.stdout: | ||
results = SolverFactory(subsolver).solve( | ||
model, tee=True, timelimit=timelimit | ||
) | ||
results.solver.transformation_time = ( | ||
transformation_end_time - transformation_start_time | ||
) | ||
print(results) | ||
elif strategy in [ | ||
"gdpopt.enumerate", | ||
"gdpopt.loa", | ||
"gdpopt.gloa", | ||
"gdpopt.lbb", | ||
"gdpopt.ric", | ||
]: | ||
with open( | ||
result_dir + "/" + strategy + "_" + subsolver + ".log", "w" | ||
) as sys.stdout: | ||
results = SolverFactory(strategy).solve( | ||
model, | ||
tee=True, | ||
nlp_solver=subsolver, | ||
mip_solver=subsolver, | ||
minlp_solver=subsolver, | ||
local_minlp_solver=subsolver, | ||
time_limit=timelimit, | ||
) | ||
print(results) | ||
|
||
sys.stdout = stdout | ||
with open(result_dir + "/" + strategy + "_" + subsolver + ".json", "w") as f: | ||
json.dump(results.json_repn(), f) | ||
return None | ||
|
||
|
||
if __name__ == "__main__": | ||
instance_list = [ | ||
# "batch_processing", | ||
# "biofuel", | ||
# "disease_model", | ||
# "gdp_col", | ||
# "hda", | ||
"jobshop", | ||
# "kaibel", | ||
# "logical", | ||
# "med_term_purchasing", | ||
# "methanol", | ||
# "mod_hens", | ||
# "modprodnet", | ||
# "stranded_gas", | ||
# "syngas", | ||
] | ||
strategy_list = [ | ||
"gdp.bigm", | ||
"gdp.hull", | ||
"gdpopt.enumerate", | ||
"gdpopt.loa", | ||
"gdpopt.gloa", | ||
"gdpopt.ric", | ||
] | ||
current_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") | ||
timelimit = 600 | ||
|
||
for instance in instance_list: | ||
print("Benchmarking instance: " + instance) | ||
result_dir = "gdplib/" + instance + "/benchmark_result/" | ||
os.makedirs(result_dir, exist_ok=True) | ||
|
||
model = import_module("gdplib." + instance).build_model() | ||
|
||
for strategy in strategy_list: | ||
benchmark(model, strategy, timelimit, result_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .batch_processing import build_model | ||
|
||
__all__ = ['build_model'] |
File renamed without changes.
Oops, something went wrong.