forked from cog-imperial/OMLT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linear Tree Implementation (cog-imperial#108)
* added initial linear-tree files. Created linear-tree model class * initial commit * LinearTreeModel * public vs private test * private vs public testing * public vs private testing * Initial Linear Tree Commit * ltmodel testing * ltmodel testing * ltmodel testing * ltmodel testing * recursion test find children splits * testing * recursion test find all children splits * recursion test number find all children splits * Recursion test 1 * Globalizing Function Test * Globalizing Function Test * Determine if parent information is even needed * LinearModel Testing * Lt Model Testing and commit * Cleaning Up LinearTreeModel Class code * Linear Tree Init Commiit * Raise exceptions for missing bounds/wrong transformation * changed parse_tree_data name * raise errors on unsupported GDP transformations * Bounds changes * Implemented output variable bound calculation function * adding comments to output variable bound function * Initial Linear Tree Documentation * linear tree documentation * Added Notebook for Linear Tree in Docs * Documentation * Added more documentation on comments * Updated docstrings * docstring updates * Docstring Updates * Docstring Updates * Upload the script for testing * Upload script for testing LinearTreeModel Test dictionary * Upload the test for bigm transformation * Pass pytest: fix some bus, e.g. len * Test hull formulation * Test the slope and bounds: Note that bounds may be None for other dataset * Added Hybrid Big-M Formulations * Added Multiple BigM Test * Add more comments * Added multivariate input testing for linear model decision trees * Added Hybrid Big M Formulation Tests * Docstring Updates * Added option to pass in summary rather than linear-tree instance * Added test to ensure model summary argument functions * Added Hybrid Big-M Tests * docstring updates * Docstring updates * Docstring updates * Added code to ensure input dict is correct * Added hybrid big-m representation to docs * Added testing for raised exceptions * Reassigned none bounds in lt model. Added unscaled_input_bounds karg * Initial formulation consolidation code commit * docstring updates * Docstring updates * Docstring update * Update Variable Names * Updated LinearTreeModel to LinearTreeDefinition, made helper functions internal, and added cbc as solver for MILP tests * Updated Notebook to use LinearTree Definition * Code Cleanup * Updated lineartree to linear_tree, changed _setup_scaled_inputs due to maxpool int/float issue * Install pyscipopt in main.yml * Update linear_tree notebook to use SCIP rather than gurobi * Changed quadratic formulation solver from gurobi to scip * Skip if solvers unavailable * omlt.lineartree to omlt.linear_tree * Added 'custom' transformation option to LinearTreeGDPFormulation * Ran through pylint and black * Cleaning up for linting * Fixing pylint issues * Linting * Linting * Added test for scaling LinearTreeDefinition * Linting * Edit docstring * Added properties to definition. Docstring Updates. * Removing unused properties * Docstring Updates * Linear Tree Notebook Updates * Linting * docstring update * For code coverage * Addressing requested changes * Addressing changes * Addressing ruth comments * Notebook Update * Updating README.rst. Also updated OMLT paper citation. * Modifying citation * Notebook modification * Notebook modification * Notebook docstring * Attempt tests on Python 3.10 * Testing on Python 3.10 --------- Co-authored-by: Shumeng Lin <[email protected]>
- Loading branch information
1 parent
dcca13c
commit b60bf0d
Showing
14 changed files
with
3,120 additions
and
14 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
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,20 @@ | ||
Linear Model Decision Trees | ||
============================ | ||
|
||
.. automodule:: omlt.linear_tree.__init__ | ||
|
||
Linear Tree Definition | ||
----------------------- | ||
|
||
.. automodule:: omlt.linear_tree.lt_definition | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Linear Tree Formulations | ||
------------------------- | ||
|
||
.. automodule:: omlt.linear_tree.lt_formulation | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ API Documentation | |
omlt.scaling | ||
omlt.io | ||
omlt.gbt | ||
omlt.neuralnet | ||
omlt.neuralnet | ||
omlt.linear_tree |
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
29 changes: 26 additions & 3 deletions
29
docs/notebooks/bo_with_trees.ipynb → docs/notebooks/trees/bo_with_trees.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,463 changes: 1,463 additions & 0 deletions
1,463
docs/notebooks/trees/linear_tree_formulations.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -76,6 +76,7 @@ testing = | |
ipywidgets | ||
jupyter | ||
lightgbm | ||
linear-tree | ||
matplotlib | ||
pandas | ||
keras | ||
|
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,24 @@ | ||
r""" | ||
There are multiple formulations for representing linear model decision trees. | ||
Please see the following reference: | ||
* Ammari et al. (2023) Linear Model Decision Trees as Surrogates in Optimization | ||
of Engineering Applications. Computers & Chemical Engineering | ||
We utilize the following common nomenclature in the formulations: | ||
.. math:: | ||
\begin{align*} | ||
L &:= \text{Set of leaves} \\ | ||
z_{\ell} &:= \text{Binary variable indicating which leaf is selected} \\ | ||
x &:= \text{Vector of input variables to the decision tree} \\ | ||
d &:= \text{Output variable from the decision tree} \\ | ||
a_{\ell} &:= \text{Vector of slopes learned by the tree for leaf } \ell \in L\\ | ||
b_{\ell} &:= \text{Bias term learned by the tree for leaf } \ell \in L\\ | ||
\end{align*} | ||
""" | ||
from omlt.linear_tree.lt_formulation import ( | ||
LinearTreeGDPFormulation, | ||
LinearTreeHybridBigMFormulation, | ||
) | ||
from omlt.linear_tree.lt_definition import LinearTreeDefinition |
Oops, something went wrong.