Skip to content

Commit

Permalink
Actually revert set?
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed Nov 15, 2024
1 parent 0dc8bc8 commit a2bd2a1
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions pyomo/core/base/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3450,40 +3450,6 @@ def __str__(self):
return self.name
return self._expression_str()

def __deepcopy__(self, memo):
# SetOperators form an expression system. As we allow operators
# on abstract Set objects, it is important to *always* deepcopy
# SetOperators that have not been assigned to a Block. For
# example, consider an abstract indexed model component whose
# domain is specified by a Set expression:
#
# def x_init(m,i):
# if i == 2:
# return Set.Skip
# else:
# return []
# m.x = Set( [1,2],
# domain={1: m.A*m.B, 2: m.A*m.A},
# initialize=x_init )
#
# We do not want to automatically add all the Set operators to
# the model at declaration time, as m.x[2] is never actually
# created. Plus, doing so would require complex parsing of the
# initializers. BUT, we need to ensure that the operators are
# deepcopied, otherwise when the model is cloned before
# construction the operators will still refer to the sets on the
# original abstract model (in particular, the Set x will have an
# unknown dimen).
#
# Our solution is to cause SetOperators to be automatically
# cloned if they haven't been assigned to a block.
if '__block_scope__' in memo:
if self.parent_block() is None:
# Hijack the block scope rules to cause this object to
# be deepcopied.
memo['__block_scope__'][id(self)] = True
return super(SetOperator, self).__deepcopy__(memo)

def _expression_str(self):
_args = []
for arg in self._sets:
Expand Down

0 comments on commit a2bd2a1

Please sign in to comment.