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

Network interdiction problems are broken #15

Open
stigrs opened this issue Jul 8, 2020 · 0 comments
Open

Network interdiction problems are broken #15

stigrs opened this issue Jul 8, 2020 · 0 comments

Comments

@stigrs
Copy link

stigrs commented Jul 8, 2020

I get the following error when I try to run, e.g., the min_cost_flow_interdict example:

`MultiIndex([( 'B', 'End'),
( 'C', 'B'),
( 'C', 'D'),
( 'D', 'End'),
('Start', 'B'),
('Start', 'C')],
names=['StartNode', 'EndNode'])
ERROR: Constructing component 'edge_set' from data=None failed: ValueError:
The truth value of a MultiIndex is ambiguous. Use a.empty, a.bool(),
a.item(), a.any() or a.all().

ValueError Traceback (most recent call last)
in
227
228 if name == 'main':
--> 229 m = MinCostFlowInterdiction('sample_nodes_data.csv', 'sample_arcs_data.csv')
230 m.solve()
231 m.printSolution()

in init(self, nodefile, arcfile, attacks)
44 self.nCmax = len(self.node_set) * self.arc_data['Cost'].max()
45
---> 46 self.createPrimal()
47 self.createInterdictionDual()
48

in createPrimal(self)
59 # Add the sets
60 model.node_set = pe.Set( initialize=self.node_set )
---> 61 model.edge_set = pe.Set( initialize=self.arc_set, dimen=2)
62
63 # Create the variables

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\block.py in setattr(self, name, val)
541 # Pyomo components are added with the add_component method.
542 #
--> 543 self.add_component(name, val)
544 else:
545 #

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\block.py in add_component(self, name, val)
1079 _blockName, str(data))
1080 try:
-> 1081 val.construct(data)
1082 except:
1083 err = sys.exc_info()[1]

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\util.py in construct(self, data)
123 self._name = base.name
124 self.class = base
--> 125 return base.construct(self, data)
126 construct.doc = base.construct.doc
127 cls.construct = construct

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in construct(self, data)
1987 # Bypass the index validation and create the member directly
1988 for index in self.index_set():
-> 1989 self._getitem_when_not_present(index)
1990 finally:
1991 # Restore the original initializer (if overridden by data argument)

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in _getitem_when_not_present(self, index)
2030 self._init_values._dimen = _d
2031 try:
-> 2032 _values = self._init_values(_block, index)
2033 except TuplizeError as e:
2034 raise ValueError( str(e) % (

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pyomo\core\base\set.py in call(self, parent, index)
412 elif _val is Set.Skip:
413 return _val
--> 414 elif not _val:
415 return _val
416

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pandas\core\indexes\base.py in nonzero(self)
2148 def nonzero(self):
2149 raise ValueError(
-> 2150 f"The truth value of a {type(self).name} is ambiguous. "
2151 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
2152 )

ValueError: The truth value of a MultiIndex is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant