Hey everyone,
I had the unfortunate idea of updating cplex in my computer, but after doing that I can't run any notebook using the docplex library. Everytime I tried the following error appears:
With cplex 12.8, it was working normally.
Any suggestions.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-dd5ac9c2ee34> in <module>()
6 for i in range(2,3):
7 print(i)
----> 8 LB,runtimetotal,UB,FirstLB,gap,cnt,case,status = AvoidanceRelaxed(i,cp)
9 print('\n>>> MAIN')
10 print(i,LB,UB,runtimetotal,FirstLB,gap,cnt,case,status,file=d)
<ipython-input-7-cd16611bc907> in AvoidanceRelaxed(n, nps)
63 # z constraint
64 for (i,j) in P:
---> 65 model.add_constraint(xr0[(i,j)]*vy[(i,j)] - yr0[(i,j)]*vx[(i,j)] <= (1- z[(i,j)])*Mbin11[(i,j)])
66 model.add_constraint(xr0[(i,j)]*vy[(i,j)] - yr0[(i,j)]*vx[(i,j)] >= -z[(i,j)]*Mbin12[(i,j)])
67
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\model.py in add_constraint(self, ct, ctname)
3325 :func:`add_constraint_`
3326 """
-> 3327 ct = self._add_constraint_internal(ct, ctname)
3328 return ct
3329
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\model.py in _add_constraint_internal(self, ct, ctname)
2811 check_trivial = self._checker.check_trivial_constraints()
2812 if self._prepare_constraint(ct, used_ct_name, check_for_trivial_ct=check_trivial):
-> 2813 self._post_constraint(ct)
2814 return ct
2815 elif ct is True or ct is False:
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\model.py in _post_constraint(self, ct)
2819
2820 def _post_constraint(self, ct):
-> 2821 ct_engine_index = self._create_engine_constraint(ct)
2822 self._register_one_constraint(ct, ct_engine_index, is_ctname_safe=True)
2823 return ct
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\model.py in _create_engine_constraint(self, ct)
2697 eng = self.__engine
2698 if isinstance(ct, LinearConstraint):
-> 2699 return eng.create_linear_constraint(ct)
2700 elif isinstance(ct, RangeConstraint):
2701 return eng.create_range_constraint(ct)
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\cplex_engine.py in create_linear_constraint(self, binaryct)
770 return self._make_cplex_linear_ct(cpx_lin_expr=cpx_linexp,
771 cpx_sense=binaryct.cplex_code(),
--> 772 rhs=num_rhs, name=binaryct.get_name())
773
774 def create_block_linear_constraints(self, linct_seq):
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\cplex_engine.py in _make_cplex_linear_ct(self, cpx_lin_expr, cpx_sense, rhs, name)
758 cpxnames = [name] if name else []
759
--> 760 ret_add = fast_add_linear(self._cplex, cpx_lin_expr, cpx_sense, cpx_rhs, cpxnames)
761 return self._allocate_one_index(ret_value=ret_add, scope=self._lincts_scope, expect_range=True)
762
~\AppData\Roaming\Python\Python36\site-packages\docplex\mp\cplex_engine.py in fast_add_linear(cpx, lin_expr, cpx_senses, rhs, names, ranges)
129 cpxenv = cpx._env
130 with chbmatrix(lin_expr, cpx._env_lp_ptr, 0,
--> 131 cpxenv._apienc) as (rmat, nnz):
132 addrows(cpxenv._e, cpx._lp, 0,
133 len(rhs), nnz, rhs, cpx_senses,
AttributeError: 'Environment' object has no attribute '_apienc'
------------------------------
Fernando Dias
------------------------------
#DecisionOptimization