Ask Your Question

bucks65's profile - activity

2021-11-09 06:08:21 +0100 received badge  Notable Question (source)
2020-10-02 07:47:27 +0100 received badge  Popular Question (source)
2019-05-22 18:31:15 +0100 answered a question using cplex as a solver in sage - import error undefined symbol: CPXsetlogfile

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!

2019-05-22 18:28:13 +0100 received badge  Scholar (source)
2019-05-22 11:27:17 +0100 received badge  Editor (source)
2019-05-22 00:02:31 +0100 received badge  Student (source)
2019-05-21 14:52:39 +0100 asked a question using cplex as a solver in sage - import error undefined symbol: CPXsetlogfile

Hi,

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:

doc.sagemath.org/html/en/thematic_tutorials/linear_programming

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/cplex_backend.so: 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.

Thanks.


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)
    355 
    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.")
   1648 
-> 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)()
   1794 
   1795     elif solver == "Cplex":
-> 1796         from sage.numerical.backends.cplex_backend import CPLEXBackend
   1797         return CPLEXBackend()
   1798 

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