IBMDecisionOptimization / docplex-examples

These samples demonstrate how to use the DOcplex library to model and solve optimization problems.
https://ibmdecisionoptimization.github.io/
Apache License 2.0
396 stars 228 forks source link

Error in using add_indicator_constraints() #8

Closed jfpinedap closed 5 years ago

jfpinedap commented 5 years ago

When run this CVRP example that use add_indicator_constraint() method, I get this Error:


TypeError Traceback (most recent call last)

in 7 b 8 ----> 9 mdl.add_indicator_constraints_(mdl.indicator_constraint(x[i, j], u[i] + q[j] == u[j]) for i, j in arcs if i != 0 and j != 0) 10 11 /usr/local/lib/python3.6/dist-packages/docplex/mp/model.py in add_indicator_constraints(self, indcts) 2913 :func:`indicator_constraint` 2914 """ -> 2915 ind_indices = self.__engine.create_batch_indicator_constraints(indcts) 2916 self._register_block_cts(self._indicator_scope, indcts, ind_indices) 2917 add_indicator_constraints_ = add_indicator_constraints /usr/local/lib/python3.6/dist-packages/docplex/mp/engine.py in create_batch_indicator_constraints(self, indicators) 431 432 def create_batch_indicator_constraints(self, indicators): --> 433 return self.create_batch_cts(indicators) 434 435 def create_quadratic_constraint(self, ind): /usr/local/lib/python3.6/dist-packages/docplex/mp/engine.py in create_batch_cts(self, ct_seq) 415 def create_batch_cts(self, ct_seq): 416 old_ct_count = self._ct_counter --> 417 self._increment_cts(len(ct_seq)) 418 return range(old_ct_count, self._ct_counter) 419 TypeError: object of type 'generator' has no len()
vlkong commented 5 years ago

This will be fixed in the next release (dev worked on it, on the waiting list for publish)

vlkong commented 5 years ago

docplex 2.10.150 is deployed and should fix this. Please update and check.