Ask Your Question

using cplex as a solver in sage - import error undefined symbol: CPXsetlogfile

asked 2019-05-21 13:36:42 +0200

bucks65 gravatar image

updated 2019-05-22 11:27:17 +0200


Ubuntu 18.04; Installed cplex_studio129.linux-x86-64.bin and then Sage 8.7 from source.

I chose source to allow me to "make" Sage again after linking the necessary CPLEX files as described at the very bottom of the page here:

i.e. from /home/klara/sage-8.7/local/lib

ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/lib/x86-64_linux/static_pic/libcplex.a .

and from: /home/klara/sage-8.7/local/include

ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/include/ilcplex/cplex.h .

and finally, also from: /home/klara/sage-8.7/local/include

ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/include/ilcplex/cpxconst.h .

But now I get the following import error when running:

sage: p = MixedIntegerLinearProgram(solver='CPLEX')

ImportError: /home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/ undefined symbol: CPXsetlogfile

(By the way, after installing Sage but before linking and remaking I got the more basic import error: ImportError: No module named cplex_backend)

Any hints as what to look into would be appreciated.


Here is the Full Output of the error:

sage: p = MixedIntegerLinearProgram(solver='CPLEX')
ImportError                               Traceback (most recent call last)
<ipython-input-1-d320ed52392f> in <module>()
----> 1 p = MixedIntegerLinearProgram(solver='CPLEX')

/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3690)()
    352             True
    353         """
--> 354         return self.get_object()(*args, **kwds)
    356     def __repr__(self):

/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.__init__ (build/cythonized/sage/numerical/mip.c:3931)()
    449         self._first_variable_names = list(names)
    450         from sage.numerical.backends.generic_backend import get_solver
--> 451         self._backend = get_solver(solver=solver,
    452                                    constraint_generation=constraint_generation,
    453                                    base_ring=base_ring)

/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/generic_backend.pyx in sage.numerical.backends.generic_backend.get_solver (build/cythonized/sage/numerical/backends/generic_backend.c:20060)()
   1647         raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'Gurobi', 'PPL', 'InteractiveLP', or None.")
-> 1649 cpdef GenericBackend get_solver(constraint_generation = False, solver = None, base_ring = None):
   1650     """
   1651     Return a solver according to the given preferences

/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/generic_backend.pyx in sage.numerical.backends.generic_backend.get_solver (build/cythonized/sage/numerical/backends/generic_backend.c:19611)()
   1795     elif solver == "Cplex":
-> 1796         from sage.numerical.backends.cplex_backend import CPLEXBackend
   1797         return CPLEXBackend()

ImportError: /home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/ undefined symbol: CPXsetlogfile
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-05-22 11:50:34 +0200

CPXsetlogfile has been deprecated in cplex 12.8 and removed from cplex 12.9.

See ticket

edit flag offensive delete link more


Thanks David Coudert, that seems to have sorted it.

I installed CPlex 12.7 binary (instead of 12.9) with Sage 8.7 installed from source, as described above, and it seems to work now.

I really appreciate your help. Thanks!

bucks65 gravatar imagebucks65 ( 2019-05-22 18:31:15 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-05-21 13:36:42 +0200

Seen: 450 times

Last updated: May 22 '19