Skip to content

Commit

Permalink
Merge branch 'main' into benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedongPeng authored Jan 29, 2024
2 parents 43f0d24 + f7fa223 commit 70fe040
Show file tree
Hide file tree
Showing 140 changed files with 547 additions and 589 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ ed13c8c65d6c3f56973887744be1c62a5d4756de
0d93f98aa608f892df404ad8015885d26e09bb55
63a3c602a00a2b747fc308c0571bbe33e55a3731
363a16a609f519b3edfdfcf40c66d6de7ac135af
d024718991455519e09149ede53a38df1c067abe
017e21ee50d98d8b2f2083e6880f030025ed5378

2 changes: 1 addition & 1 deletion doc/OnlineDocs/src/scripting/abstract2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# abstract2.py

from __future__ import division

from pyomo.environ import *

model = AbstractModel()
Expand Down
1 change: 0 additions & 1 deletion doc/OnlineDocs/src/scripting/concrete1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import division
from pyomo.environ import *

model = ConcreteModel()
Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/src/scripting/driveabs2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# driveabs2.py
from __future__ import division

import pyomo.environ as pyo
from pyomo.opt import SolverFactory

Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/src/scripting/driveconc1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# driveconc1.py
from __future__ import division

import pyomo.environ as pyo
from pyomo.opt import SolverFactory

Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/src/scripting/spy4Constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Constraints.rst in testable form
"""

from pyomo.environ import *

model = ConcreteModel()
Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/src/scripting/spy4Expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Expressions.rst in testable form
"""

from pyomo.environ import *

model = ConcreteModel()
Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for PyomoCommand.rst in testable form
"""

from pyomo.environ import *

model = ConcreteModel()
Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/src/scripting/spy4Variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Variables.rst in testable form
"""

from pyomo.environ import *

model = ConcreteModel()
Expand Down
2 changes: 1 addition & 1 deletion examples/dae/stochpdegas_automatic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# stochastic pde model for natural gas network
# victor m. zavala / 2013

# from __future__ import division
#

from pyomo.environ import *
from pyomo.dae import *
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/constrained_layout/cons_layout_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
with each other.
"""
from __future__ import division

from pyomo.environ import ConcreteModel, Objective, Param, RangeSet, Set, Var, value

Expand Down
1 change: 0 additions & 1 deletion examples/gdp/eight_process/eight_proc_logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
http://dx.doi.org/10.1016/0098-1354(95)00219-7
"""
from __future__ import division

from pyomo.core.expr.logical_expr import land, lor
from pyomo.core.plugins.transform.logical_to_linear import (
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/eight_process/eight_proc_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
http://dx.doi.org/10.1016/0098-1354(95)00219-7
"""
from __future__ import division

from pyomo.environ import (
ConcreteModel,
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/eight_process/eight_proc_verbose_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
eight_proc_model.py.
"""
from __future__ import division

from pyomo.environ import (
ConcreteModel,
Expand Down
1 change: 1 addition & 0 deletions examples/gdp/nine_process/small_process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Small process synthesis-inspired toy GDP example.
"""

from pyomo.core import ConcreteModel, RangeSet, Var, Constraint, Objective
from pyomo.core.expr.current import exp, log, sqrt
from pyomo.gdp import Disjunction
Expand Down
1 change: 1 addition & 0 deletions examples/gdp/small_lit/basic_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Pyomo model implementation by @RomeoV
"""

from pyomo.environ import *
from pyomo.gdp import *
from pyomo.gdp.basic_step import apply_basic_step
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/small_lit/ex_633_trespalacios.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Pyomo model implementation by @bernalde and @qtothec.
"""
from __future__ import division

from pyomo.environ import *
from pyomo.gdp import *
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/small_lit/nonconvex_HEN.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Pyomo model implementation by @RomeoV
"""


from pyomo.environ import (
ConcreteModel,
Constraint,
Expand Down
2 changes: 0 additions & 2 deletions examples/gdp/strip_packing/strip_packing_8rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"""

from __future__ import division

from pyomo.environ import (
ConcreteModel,
NonNegativeReals,
Expand Down
1 change: 0 additions & 1 deletion examples/gdp/strip_packing/strip_packing_concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
cutting fabric.
"""
from __future__ import division

from pyomo.environ import ConcreteModel, NonNegativeReals, Objective, Param, Set, Var

Expand Down
1 change: 0 additions & 1 deletion examples/gdp/two_rxn_lee/two_rxn_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Two reactor model from literature. See README.md."""
from __future__ import division

from pyomo.core import ConcreteModel, Constraint, Objective, Param, Var, maximize

Expand Down
4 changes: 1 addition & 3 deletions examples/kernel/mosek/power1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def solve_nonlinear():

m.c = pmo.constraint(body=m.x + m.y + 0.5 * m.z, rhs=2)

m.o = pmo.objective(
(m.x**0.2) * (m.y**0.8) + (m.z**0.4) - m.x, sense=pmo.maximize
)
m.o = pmo.objective((m.x**0.2) * (m.y**0.8) + (m.z**0.4) - m.x, sense=pmo.maximize)

m.x.value, m.y.value, m.z.value = (1, 1, 1)
ipopt = pmo.SolverFactory("ipopt")
Expand Down
2 changes: 1 addition & 1 deletion examples/performance/dae/stochpdegas1_automatic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# stochastic pde model for natural gas network
# victor m. zavala / 2013

# from __future__ import division
#

from pyomo.environ import *
from pyomo.dae import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def create_model(k1, k2, k3, caf):

model.cc_bal = pyo.Constraint(expr=(0 == -model.sv * model.cc + k2 * model.cb))

model.cd_bal = pyo.Constraint(
expr=(0 == -model.sv * model.cd + k3 * model.ca**2.0)
)
model.cd_bal = pyo.Constraint(expr=(0 == -model.sv * model.cd + k3 * model.ca**2.0))

return model

Expand Down
1 change: 0 additions & 1 deletion examples/pyomobook/pyomo-components-ch/var_declaration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
import pyomo.environ as pyo

model = pyo.ConcreteModel()
Expand Down
8 changes: 5 additions & 3 deletions pyomo/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,9 +1396,11 @@ def _item_body(self, indent, obj):
None,
[
'dict' if isinstance(obj, ConfigDict) else obj.domain_name(),
'optional'
if obj._default is None
else f'default={repr(obj._default)}',
(
'optional'
if obj._default is None
else f'default={repr(obj._default)}'
),
],
)
)
Expand Down
12 changes: 6 additions & 6 deletions pyomo/contrib/community_detection/community_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def generate_model_graph(
]

# Update constraint_variable_map
constraint_variable_map[
numbered_constraint
] = numbered_variables_in_constraint_equation
constraint_variable_map[numbered_constraint] = (
numbered_variables_in_constraint_equation
)

# Create a list of all the edges that need to be created based on the variables in this constraint equation
edges_between_nodes = [
Expand All @@ -145,9 +145,9 @@ def generate_model_graph(
]

# Update constraint_variable_map
constraint_variable_map[
numbered_objective
] = numbered_variables_in_objective
constraint_variable_map[numbered_objective] = (
numbered_variables_in_objective
)

# Create a list of all the edges that need to be created based on the variables in the objective function
edges_between_nodes = [
Expand Down
39 changes: 17 additions & 22 deletions pyomo/contrib/community_detection/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Original implementation developed by Rahul Joglekar in the Grossmann research group.
"""

from logging import getLogger

from pyomo.common.dependencies import attempt_import
Expand Down Expand Up @@ -453,16 +454,14 @@ def visualize_model_graph(
if type_of_graph != self.type_of_community_map:
# Use the generate_model_graph function to create a NetworkX graph of the given model (along with
# number_component_map and constraint_variable_map, which will be used to help with drawing the graph)
(
model_graph,
number_component_map,
constraint_variable_map,
) = generate_model_graph(
self.model,
type_of_graph=type_of_graph,
with_objective=self.with_objective,
weighted_graph=self.weighted_graph,
use_only_active_components=self.use_only_active_components,
(model_graph, number_component_map, constraint_variable_map) = (
generate_model_graph(
self.model,
type_of_graph=type_of_graph,
with_objective=self.with_objective,
weighted_graph=self.weighted_graph,
use_only_active_components=self.use_only_active_components,
)
)
else:
# This is the case where, as mentioned above, we can use the networkX graph that was made to create
Expand Down Expand Up @@ -726,13 +725,10 @@ def generate_structured_model(self):
variable_in_new_model = structured_model.find_component(
new_variable
)
blocked_variable_map[
variable_in_stored_constraint
] = blocked_variable_map.get(
variable_in_stored_constraint, []
) + [
variable_in_new_model
]
blocked_variable_map[variable_in_stored_constraint] = (
blocked_variable_map.get(variable_in_stored_constraint, [])
+ [variable_in_new_model]
)

# Update replace_variables_in_expression_map accordingly
replace_variables_in_expression_map[
Expand Down Expand Up @@ -802,11 +798,10 @@ def generate_structured_model(self):
variable_in_new_model = structured_model.find_component(
new_variable
)
blocked_variable_map[
variable_in_objective
] = blocked_variable_map.get(variable_in_objective, []) + [
variable_in_new_model
]
blocked_variable_map[variable_in_objective] = (
blocked_variable_map.get(variable_in_objective, [])
+ [variable_in_new_model]
)

# Update the dictionary that we will use to replace the variables
replace_variables_in_expression_map[
Expand Down
1 change: 0 additions & 1 deletion pyomo/contrib/community_detection/tests/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

from __future__ import division

import logging

Expand Down
3 changes: 1 addition & 2 deletions pyomo/contrib/cp/interval_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def __init__(
optional=False,
name=None,
doc=None
):
...
): ...

def __init__(self, *args, **kwargs):
_start_arg = kwargs.pop('start', None)
Expand Down
Loading

0 comments on commit 70fe040

Please sign in to comment.