Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Expression Branch #272

Merged
merged 759 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
759 commits
Select commit Hold shift + click to select a range
117009a
Two major changes to inequalities
whart222 Jan 17, 2018
9e7178f
Updating constraint logic and testing
whart222 Jan 17, 2018
62bde83
Updates to use RangedExpression objects
whart222 Jan 17, 2018
0bd86b1
Updates to use RangedExpression objects
whart222 Jan 17, 2018
8a68805
Changes to eliminate ranged expressions
whart222 Jan 17, 2018
6585e7c
Removing chained inequalities
whart222 Jan 17, 2018
b4a7af8
Getting rid of chained inequalities.
whart222 Jan 17, 2018
cc0469e
Removing chained inequality expressions
whart222 Jan 17, 2018
8cd29f7
Removing chained inequality expressions
whart222 Jan 17, 2018
749da07
Removing chained inequality expressions
whart222 Jan 17, 2018
ac86113
Explicit construction of ranged expression
whart222 Jan 19, 2018
88426b1
Adding the inequality() function.
whart222 Jan 19, 2018
634512a
Removing tests with chained inequalities
whart222 Jan 19, 2018
60379ef
Updating examples to use the inequality() func.
whart222 Jan 19, 2018
d7ede57
Remove chained inequalities from tests.
whart222 Jan 19, 2018
e014df6
Removing the inequality() method.
whart222 Jan 19, 2018
583b4cf
Merge branch 'master' into expr_dev
whart222 Jan 20, 2018
0f60bb5
Updating to use the standard repn
whart222 Jan 20, 2018
c354c91
Changes to account for new param semantics.
whart222 Jan 20, 2018
84df5c3
Misc changes to resolve merge issues
whart222 Jan 20, 2018
7c6ecaf
Misc test updates
whart222 Jan 20, 2018
2968810
Misc change to resolve merge issue
whart222 Jan 20, 2018
e2e83ff
Change to use the the standard repn
whart222 Jan 20, 2018
4b1d7d4
Adding walker to find mutable params
whart222 Jan 22, 2018
3852768
Merge branch 'expr_dev' of https://github.com/Pyomo/pyomo into expr_dev
whart222 Jan 22, 2018
23a8bea
Renaming function:
whart222 Jan 22, 2018
e46a3ec
Removing expression walkers
whart222 Jan 22, 2018
67d54c0
Changes to expression mngmnt
whart222 Jan 25, 2018
6a83051
Fixing typo
whart222 Jan 28, 2018
1d2d322
A linear constant sum is just a constant
whart222 Jan 28, 2018
7a9aeed
Several significant changes to pyomo5 expressions
whart222 Jan 29, 2018
cdbed6a
Several changes
whart222 Jan 29, 2018
edd9b8f
Recognize when chained inequalities are disabled
whart222 Jan 29, 2018
1498fc0
Several testing changes
whart222 Jan 29, 2018
44fb53d
Misc baseline update
whart222 Jan 29, 2018
0844bfb
Baseline updates
whart222 Jan 29, 2018
ba112e4
Several fixes in repn logic
whart222 Jan 29, 2018
726d0f1
Fix to use inequality()
whart222 Jan 29, 2018
9f21ab0
Adding a deprecation warning
whart222 Jan 29, 2018
c9db025
Merge branch 'master' into expr_dev
whart222 Jan 29, 2018
639d047
Resolving import issues
whart222 Jan 29, 2018
88e9e59
Disabling scipy when using PyPy
whart222 Feb 3, 2018
8a071f3
PyPy portability fix
whart222 Feb 3, 2018
e7f6741
Baseline fix
whart222 Feb 3, 2018
c6b61b9
Skiping tests based on scipy
whart222 Feb 3, 2018
662aebe
Updates to use new expression syntax
whart222 Feb 3, 2018
2bc3fa0
Merge branch 'master' into expr_dev
whart222 Feb 3, 2018
dd840c3
Updating to use standard repn
whart222 Feb 3, 2018
855c411
Reverting baseline
whart222 Feb 3, 2018
f76f6e7
For now, disabled processing for connectors
whart222 Feb 3, 2018
7807d23
Mostly documentation updates.
whart222 Feb 7, 2018
75dc887
Some performance optimizations
whart222 Feb 11, 2018
0ca01c0
Changes to support cython
whart222 Feb 11, 2018
c2989f1
Tuning performance of Sum()
whart222 Feb 12, 2018
92f2758
Updating Cythonization.
whart222 Feb 18, 2018
9305c5b
Cythonizing numvalue.py
whart222 Feb 19, 2018
b3e2aca
Adding Cythonized *.c file.
whart222 Feb 19, 2018
598fbdf
Ignore *.pyx files
whart222 Feb 24, 2018
65a8afb
Removing null command
whart222 Feb 24, 2018
f14e6f5
Adding polynomial_degree()
whart222 Feb 24, 2018
487ddf8
Misc test fixes
whart222 Feb 24, 2018
1a1b47c
Catching runtime error.
whart222 Feb 24, 2018
6564bce
Adding --with-cython installation flag
whart222 Feb 24, 2018
b676e0b
Renaming Sum to quicksum
whart222 Feb 24, 2018
7c054e7
Removing reference to Sum().
whart222 Feb 24, 2018
ed60fec
Misc edits
whart222 Feb 24, 2018
2723b1a
Renaming Sum to quicksum
whart222 Feb 28, 2018
dedd2a2
Perparing for Pyomo 5.4 release
whart222 Feb 28, 2018
efac071
Updating release version
whart222 Feb 28, 2018
58b5fbe
Several performance optimizations
whart222 Mar 4, 2018
c19c077
Adding bilinear tests.
whart222 Mar 4, 2018
2ffb004
Bug fix
whart222 Mar 5, 2018
9286053
Bug fix to ignore 0 nonlinear terms
whart222 Mar 5, 2018
f06eaab
Baseline updates
whart222 Mar 5, 2018
c5b437d
Several changes
whart222 Mar 5, 2018
cfbef78
Explicitly construct context manager
whart222 Mar 5, 2018
e785a14
Misc documentation update
whart222 Mar 5, 2018
341e335
Misc optimization
whart222 Mar 6, 2018
1c27f50
Adding performance optimization for lienar expr
whart222 Mar 13, 2018
b07dfc1
New tests to improve code coverage
whart222 Mar 13, 2018
de341c6
Removing commented code
whart222 Mar 13, 2018
3cfcd77
Simplifying normalization of equalities
whart222 Mar 13, 2018
82ed323
Baseline updates
whart222 Mar 13, 2018
be46a83
Adding TermExpression
whart222 Mar 13, 2018
2c1f1cb
Changes to recognize linear terms in tests.
whart222 Mar 13, 2018
c966bee
Changes to ...
whart222 Mar 13, 2018
9e20332
Process TermExpression objects
whart222 Mar 13, 2018
c8452fd
Merge branch 'master' into expr_dev
whart222 Mar 13, 2018
0b6d287
Baseline update
whart222 Mar 13, 2018
0519300
Update to use Pyomo5 API
whart222 Mar 13, 2018
5a313d5
Updating test checks
whart222 Mar 13, 2018
d33a553
Updated to use StandardRepn API
whart222 Mar 13, 2018
e6f8b6b
More aggressive optimizations
whart222 Mar 13, 2018
618cbde
Baseline update
whart222 Mar 13, 2018
a045748
Baseline updates
whart222 Mar 13, 2018
dc2eb6b
Fix in exception name
whart222 Mar 13, 2018
abba5b7
Update to use Pyomo5 expressions
whart222 Mar 13, 2018
e9b5f6b
Adding an expression walker
whart222 Mar 13, 2018
8af81cd
Many revisions to tests
whart222 Mar 13, 2018
3e849f3
Fix to ignore expression with base value of None
whart222 Mar 13, 2018
dbd6ef9
Removing symbols that were removed...
whart222 Mar 13, 2018
e56559a
Adding function to process constant
whart222 Mar 13, 2018
36f9b8f
Update to baseline check
whart222 Mar 14, 2018
8421ea4
Fixing EXPR import
whart222 Mar 14, 2018
3142694
Removing unused file.
whart222 Mar 14, 2018
f1dd269
Removing unused file
whart222 Mar 14, 2018
61a3611
Various optimizations
whart222 Mar 15, 2018
33093e7
Additional changes to use TermExpression objects
whart222 Mar 15, 2018
7b510b7
Simplification of linear decomposition
whart222 Mar 15, 2018
5c6da94
Reorder collection of summation terms
whart222 Mar 15, 2018
e882c28
Baseline updates
whart222 Mar 15, 2018
01ec07f
Several changes.
whart222 Mar 15, 2018
6a98890
Misc optimization
whart222 Mar 15, 2018
34e5610
Cython bug fixes
whart222 Mar 15, 2018
067b52b
Bug fix
whart222 Mar 15, 2018
2aa173b
Bug fixes
whart222 Mar 15, 2018
e174211
Commenting out unused code.
whart222 Mar 20, 2018
a98a74f
Updating test
whart222 Mar 20, 2018
0ec77e4
Bug fix
whart222 Mar 20, 2018
ceb3215
More careful replacement of terms
whart222 Mar 20, 2018
150a1d3
Adding test failure category
whart222 Mar 20, 2018
00c0dea
Misc change when comparing with zero.
whart222 Mar 20, 2018
af5b0cd
Building Gurobi expressions more quickly
whart222 Mar 20, 2018
e4ce0f5
Disabling expression normalization in __str__
whart222 Mar 21, 2018
cfdd17d
Adding a 'sort' option for to_expression()
whart222 Mar 21, 2018
ca36868
Bug fix.
whart222 Mar 21, 2018
23bddef
Checkout the expr_dev branch
whart222 Mar 21, 2018
5d91bcd
Bug fix: variable misnamed
whart222 Mar 21, 2018
75386c7
Merge branch 'expr_dev' of https://github.com/Pyomo/pyomo into expr_dev
whart222 Mar 21, 2018
dd16fb8
New cases where TermExpressions are used
whart222 Mar 21, 2018
de7e477
Updates to improve core coverage
whart222 Mar 21, 2018
6b732cd
Fixing cloning logic
whart222 Mar 21, 2018
38875d0
NFC: cleanup whitespace
ghackebeil Mar 21, 2018
36263a8
fix for coverage
ghackebeil Mar 21, 2018
874142c
NFC: cleanup whitespace
ghackebeil Mar 21, 2018
b33eaf8
additional tests for coverage of kernel components
ghackebeil Mar 21, 2018
c9caa28
fixing typo
ghackebeil Mar 21, 2018
ee239a2
more fixes and unit tests to finish covering kernel
ghackebeil Mar 21, 2018
9265344
removing some confusing implicit behavior from kernel constraint
ghackebeil Mar 21, 2018
f087ab7
fixing up kernel namespace to get example test working again
ghackebeil Mar 21, 2018
93229dc
Updating tests dependent on GLPK
whart222 Mar 22, 2018
b556501
removing unneeded test categorization
ghackebeil Mar 23, 2018
53b86ab
Merge branch 'master' into expr_dev (and handle some conflicts in PyS…
ghackebeil Mar 23, 2018
07bc3a1
removing cAmpl code: this has not been touched or used in years (and …
ghackebeil Mar 23, 2018
a643e9f
NFC: cleaning tabs and spaces in test files
ghackebeil Mar 24, 2018
d05bf89
fixing ampl test so that functions are evaluated within their domain
ghackebeil Mar 24, 2018
dce6787
tweaking test so it matches ampl expression output
ghackebeil Mar 24, 2018
b16a886
tweaking test so it almost matches ampl expression output (requires s…
ghackebeil Mar 24, 2018
f6f9ab3
is_expression was renamed to is_expression_type
ghackebeil Mar 24, 2018
e10f09c
fixing generator function: return (None) should be used in place of r…
ghackebeil Mar 26, 2018
f7d6241
Baseline updates
whart222 Mar 27, 2018
e14cb66
Updating baseline.
whart222 Mar 27, 2018
69eddbd
Bug fix. Recognize when we have a fixed expr.
whart222 Mar 27, 2018
f0148eb
Don't add linear terms with 0 coef
whart222 Mar 27, 2018
e8262c3
Changes to test categories
whart222 Mar 28, 2018
d710ee3
Fixing documentation errors
whart222 Mar 28, 2018
1cbe212
Various changes
whart222 Apr 4, 2018
331c60e
Renaming summation to sum_product
whart222 Apr 4, 2018
a51596e
Removing most references to isclose()
whart222 Apr 4, 2018
cf5480b
Bug fix when detecting a zero constant
whart222 Apr 4, 2018
1ea0cd7
Various changes to remove isclose()
whart222 Apr 4, 2018
5d9f9dc
Renaming TermExpr to MonomialTermExpr
whart222 Apr 4, 2018
3e40eff
Renaming sum expression objects
whart222 Apr 4, 2018
ebff9b9
Adding the Expr_if function.
whart222 Apr 4, 2018
ec79710
Updating replacement walker
whart222 Apr 4, 2018
4e3d1b6
Renaming dot_product to sum_product
whart222 Apr 4, 2018
023c13c
Bug fix
whart222 Apr 4, 2018
05cd676
Bug fix.
whart222 Apr 4, 2018
b39be0d
Updates to prod/quicksum logic.
whart222 Apr 4, 2018
4d42195
use inequality function
ghackebeil Apr 4, 2018
97fcb64
remove use of deprecated option
ghackebeil Apr 4, 2018
34f410e
use the inequality function
ghackebeil Apr 5, 2018
8ccf30b
Make PySP SMPS and DDSIP writers compatible with new StandardRepn
ghackebeil Apr 5, 2018
0239863
more pysp fixes for new expression system
ghackebeil Apr 7, 2018
4c24e91
NFC: cleanup whitespace
ghackebeil Apr 8, 2018
d182d97
more pysp fixes for new expression code
ghackebeil Apr 8, 2018
68795d1
Adding functionality to the NL writer to handle StandardRepn objects …
ghackebeil Apr 8, 2018
aac3aaa
Removing in-place methods from the named expression classes and updat…
ghackebeil Apr 9, 2018
93c5df9
removing edge-case behavior in inequality function that converts to a…
ghackebeil Apr 10, 2018
78c241f
bug in gurobi direct interface with quadratic expressions
michaelbynum Apr 11, 2018
285f4d0
fixing tests: Pyomo expressions do not do integer division (even in P…
ghackebeil Apr 12, 2018
c811aca
updating cplex direct/persistent to use the new expression system
michaelbynum Apr 13, 2018
8963744
more updates to cplex direct/persistent interfaces to use new express…
michaelbynum Apr 13, 2018
00ea254
Merge branch 'master' into expr_dev
whart222 Apr 15, 2018
82a8592
Disabling tests when numpy not installed
whart222 Apr 15, 2018
eb647ef
Removed redundant decorator
whart222 Apr 15, 2018
e05cf3a
Removing unprocessed merge comments
whart222 Apr 15, 2018
0c33b26
Bug fix
whart222 Apr 15, 2018
6e948df
Bug fix
whart222 Apr 15, 2018
818a973
Change to *not* execute merged code
whart222 Apr 15, 2018
11231c5
Simplifying several for loops
whart222 Apr 15, 2018
42b9eb5
Removing compress_expression()
whart222 Apr 15, 2018
f0200e0
Fixing issue with repn generation
whart222 Apr 16, 2018
038ca5e
Removing is_named_expression_type()
whart222 Apr 16, 2018
6a9d6cb
Renaming _PolyDegreeVisitor
whart222 Apr 16, 2018
642e62f
Renaming __public__ to _public
whart222 Apr 16, 2018
2a77d27
Renaming __public__ to _public
whart222 Apr 16, 2018
e77da93
Two changes
whart222 Apr 16, 2018
6c90ebf
Renaming context manager objects
whart222 Apr 16, 2018
560d7e3
Allocating context managers
whart222 Apr 16, 2018
38da521
Allocating context managers
whart222 Apr 16, 2018
72c910f
Documentation update
whart222 Apr 16, 2018
b6aa1c8
Reverting check for isclose()
whart222 Apr 16, 2018
e3a5a39
Baseline updates
whart222 Apr 16, 2018
7adaeca
Moved code tests before doc tests
whart222 Apr 16, 2018
5efba19
Misc documentation update
whart222 Apr 16, 2018
42654a3
Resolving bug found by Gabe
whart222 Apr 16, 2018
c162b11
Baseline updates
whart222 Apr 16, 2018
cdcc35f
Updating documentation after renaming files.
whart222 Apr 16, 2018
c3896f4
Removing Python 3.4 tests
whart222 Apr 16, 2018
4641cd8
Fixing Python 2.6 test
whart222 Apr 16, 2018
d01d404
Adding Python 3.4
whart222 Apr 16, 2018
a96e556
Adding debugging IO
whart222 Apr 16, 2018
83738f5
Removing `isclose()` test in `contrib.constraints_to_var_bounds`
jsiirola Apr 20, 2018
453b39e
Reverting change to `contrib.constraints_to_var_bounds` behavior
jsiirola Apr 20, 2018
aa7f88a
Replacing final use if isclose()
whart222 Apr 20, 2018
28cb12a
Correcting `is_potentially_variable` for expression templates.
jsiirola Apr 20, 2018
94d746e
Moving is_expression_type()
whart222 Apr 21, 2018
b926b26
Documentation update
whart222 Apr 21, 2018
167fa16
Documentation update
whart222 Apr 21, 2018
52d2189
Renaming construct_node()
whart222 Apr 21, 2018
c6ee41e
Removing _polynomial_degree() function
whart222 Apr 21, 2018
00afa99
Misc optimization
whart222 Apr 21, 2018
94b321e
Moving binary sum methods to subclass
whart222 Apr 21, 2018
6bb9b4d
Removing global clone_counter CM
whart222 Apr 22, 2018
48706e0
Moving examples into tests
whart222 Apr 22, 2018
0493795
Removing implicit reordering of products
whart222 Apr 22, 2018
00fd7aa
Adding more debugging output
whart222 Apr 23, 2018
b734bcd
Disabling __deepcopy__ customization in Pyomo5
whart222 Apr 23, 2018
405ea9c
Merge branch 'expr_dev' of https://github.com/Pyomo/pyomo into expr_dev
whart222 Apr 23, 2018
a0140cb
Fixing a bug in the Simulator
blnicho Apr 23, 2018
204a399
Removing unused expression checker in the Simulator
blnicho Apr 23, 2018
e183a44
Fixing a bug in the Simulator
blnicho Apr 23, 2018
a785767
Removing commented imports and adding simulator tests for checking ne…
blnicho Apr 23, 2018
890a36f
Clone the expr_dev branch of model libraries
whart222 Apr 24, 2018
d0ae584
Resolving #440
whart222 Apr 25, 2018
9fe320a
Merge branch 'master' into expr_dev
whart222 Apr 25, 2018
eeecdc2
Bug fix in replacement visitor.
whart222 Apr 25, 2018
ff7f460
doctest fixes
whart222 Apr 25, 2018
6ef6724
Bug fix
whart222 Apr 26, 2018
24ab5ca
Documenting expr_dev PR in CHANGELOG
whart222 Apr 26, 2018
be1f989
Merge branch 'expr_dev' of https://github.com/Pyomo/pyomo into expr_dev
jsiirola Apr 26, 2018
ce4ddc5
Merge branch 'master' into expr_dev
whart222 Apr 26, 2018
e275026
Baseline update
whart222 Apr 26, 2018
d60e494
A "bug fix" in runtime performance
whart222 Apr 26, 2018
cd53beb
Two changes
whart222 Apr 26, 2018
7157a17
Updating baseline
whart222 Apr 26, 2018
67c73aa
Baseline updates
whart222 Apr 26, 2018
7db9fb6
Reverting a change to is_potentially_variable()
whart222 Apr 26, 2018
e92309d
Test fix.
whart222 Apr 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ install:
#
# Clone but don't install pyomo-model-libraries
#
- "git clone https://github.com/Pyomo/pyomo-model-libraries.git"
- "git clone -b expr_dev https://github.com/Pyomo/pyomo-model-libraries.git"
- "python -m pip install git+https://github.com/PyUtilib/pyutilib"
- "python setup.py develop"
#
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.ropeproject

# Python generates numerous files when byte compiling / installing packages
*.pyx
*.pyc
*.pyo
*.egg-info
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ install:
#
# Clone but don't install pyomo-model-libraries
#
- git clone --quiet https://github.com/Pyomo/pyomo-model-libraries.git
- git clone -b expr_dev --quiet https://github.com/Pyomo/pyomo-model-libraries.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reverted before a merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

#
# Install PyUtilib (master branch)
#
Expand Down Expand Up @@ -163,7 +163,8 @@ script:
- test.pyomo -v --cat=$CATEGORY pyomo `pwd`/pyomo-model-libraries

# Run documentation tests
- nosetests -v --with-doctest --doctest-extension=.rst doc/OnlineDocs
- cd doc/OnlineDocs; make doctests -d; cd ../..
# nosetests -v --with-doctest --doctest-extension=.rst doc/OnlineDocs


after_success:
Expand Down
5 changes: 5 additions & 0 deletions pyomo/repn/ampl_repn.py → ATTIC/repn/ampl_repn.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,14 @@ def generate_ampl_repn(exp, idMap=None):
# We need to do this not at the global scope in case someone changed
# the mode after importing the environment.
_using_pyomo4_trees = expr_common.mode == expr_common.Mode.pyomo4_trees
_using_pyomo5_trees = expr_common.mode == expr_common.Mode.pyomo5_trees

if idMap is None:
idMap = {}
if _using_pyomo5_trees:
from pyomo.repn.standard_repn import generate_standard_repn
return generate_standard_repn(exp, quadratic=False)

if exp is None:
return AmplRepn()
degree = exp.polynomial_degree()
Expand Down
70 changes: 70 additions & 0 deletions pyomo/repn/canonical_repn.py → ATTIC/repn/canonical_repn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,72 @@ def pyomo4_generate_canonical_repn(exp, idMap=None, compute_values=True):
{ None: exp, -1 : collect_variables(exp, idMap) } )


def pyomo5_generate_canonical_repn(exp, idMap=None, compute_values=True):
from pyomo.repn.standard_repn import generate_standard_repn

if idMap is None:
idMap = {}
srepn = generate_standard_repn(exp, idMap=idMap, compute_values=compute_values)

if srepn.nonlinear_expr is None and len(srepn.quadratic_coefs) == 0:
#
# Construct linear canonical repn
#
rep = pyomo4_CompiledLinearCanonicalRepn()
if not (type(srepn.constant) in native_numeric_types and srepn.constant == 0):
rep.constant = srepn.constant
else:
rep.constant = None
if len(srepn.linear_vars) > 0:
rep.linear = srepn.linear_coefs
rep.variables = srepn.linear_vars
else:
rep.linear = None
rep.variables = None
else:
#
# Construct nonlinear canonical repn
#
ans = {}
if not srepn.nonlinear_expr is None:
ans[None] = srepn.nonlinear_expr

#print(srepn)
#print(idMap)
ans[-1] = {}
for v_ in srepn.nonlinear_vars:
ans[-1][idMap[None][id(v_)]] = v_
for v_ in srepn.linear_vars:
ans[-1][idMap[None][id(v_)]] = v_
for v1_,v2_ in srepn.quadratic_vars:
ans[-1][idMap[None][id(v1_)]] = v1_
ans[-1][idMap[None][id(v2_)]] = v2_

if not (type(srepn.constant) in native_numeric_types and srepn.constant == 0):
ans[0] = GeneralCanonicalRepn({None:srepn.constant})

if len(srepn.linear_vars) > 0:
tmp = {}
for i in range(len(srepn.linear_vars)):
v_ = srepn.linear_vars[i]
tmp[ idMap[None][id(v_)] ] = srepn.linear_coefs[i]
ans[1] = tmp

if len(srepn.quadratic_vars) > 0:
tmp = {}
for i in range(len(srepn.quadratic_vars)):
v1_,v2_ = srepn.quadratic_vars[i]
if id(v1_) == id(v2_):
terms = GeneralCanonicalRepn({idMap[None][id(v1_)]:2})
else:
terms = GeneralCanonicalRepn({idMap[None][id(v1_)]:1, idMap[None][id(v2_)]:1})
tmp[terms] = srepn.quadratic_coefs[i]
ans[2] = tmp

rep = GeneralCanonicalRepn(ans)
return rep


def canonical_is_constant(repn):
"""Return True if the canonical representation is a constant expression"""
if isinstance(repn, dict):
Expand Down Expand Up @@ -1079,12 +1145,16 @@ def generate_canonical_repn(exp, idMap=None, compute_values=True):
elif common.mode is common.Mode.pyomo4_trees:
globals()['CompiledLinearCanonicalRepn'] = pyomo4_CompiledLinearCanonicalRepn
return pyomo4_generate_canonical_repn(exp, idMap, compute_values)
elif common.mode is common.Mode.pyomo5_trees:
return pyomo5_generate_canonical_repn(exp, idMap, compute_values)
else:
raise RuntimeError("Unrecognized expression tree mode")

if common.mode is common.Mode.coopr3_trees:
CompiledLinearCanonicalRepn = coopr3_CompiledLinearCanonicalRepn
elif common.mode is common.Mode.pyomo4_trees:
CompiledLinearCanonicalRepn = pyomo4_CompiledLinearCanonicalRepn
elif common.mode is common.Mode.pyomo5_trees:
CompiledLinearCanonicalRepn = pyomo4_CompiledLinearCanonicalRepn
else:
raise RuntimeError("Unrecognized expression tree mode")
Loading