#28382 closed enhancement (fixed)

Correct types in cplex backend

Reported by: dcoudert Owned by:
Priority: major Milestone: sage-9.0
Component: numerical Keywords:
Cc: slabbe, vdelecroix Merged in:
Authors: David Coudert Reviewers: Sébastien Labbé
Report Upstream: N/A Work issues:
Branch: 94026d1 (Commits, GitHub, GitLab) Commit: 94026d1c5f9d0edd7d5885d253ff7d6a8ccc315f
Dependencies: Stopgaps:

Status badges

Description

This ticket fix the many compilation warnings of the cplex backend using correct types

build/cythonized/sage/numerical/backends/cplex_backend.c:3436:21: warning: incompatible pointer types assigning to 'struct __pyx_t_4sage_9numerical_8backends_13cplex_backend_c_cpxlp *'
      from 'CPXENVptr' (aka 'struct cpxenv *') [-Wincompatible-pointer-types]
  __pyx_v_self->env = CPXopenCPLEX((&__pyx_v_status));
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build/cythonized/sage/numerical/backends/cplex_backend.c:3468:36: warning: incompatible pointer types passing 'struct __pyx_t_4sage_9numerical_8backends_13cplex_backend_c_cpxlp *' to
      parameter of type 'CPXCENVptr' (aka 'const struct cpxenv *') [-Wincompatible-pointer-types]
  __pyx_v_self->lp = CPXcreateprob(__pyx_v_self->env, (&__pyx_v_status), __pyx_v_tmp);
                                   ^~~~~~~~~~~~~~~~~
/Users/dcoudert/sage/local/include/cplex.h:416:30: note: passing argument to parameter 'env' here
   CPXcreateprob (CPXCENVptr env, int *status_p,
                             ^
build/cythonized/sage/numerical/backends/cplex_backend.c:3468:20: warning: incompatible pointer types assigning to 'struct __pyx_t_4sage_9numerical_8backends_13cplex_backend_c_cpxlp *'
      from 'CPXLPptr' (aka 'struct cpxlp *') [-Wincompatible-pointer-types]
  __pyx_v_self->lp = CPXcreateprob(__pyx_v_self->env, (&__pyx_v_status), __pyx_v_tmp);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
128 warnings generated.

Change History (16)

comment:1 Changed 22 months ago by dcoudert

  • Branch set to public/numerical/28382_cplex
  • Commit set to 94026d1c5f9d0edd7d5885d253ff7d6a8ccc315f
  • Status changed from new to needs_review

Tickets #27089 and #27790 will have to be rebased on top of this ticket.


New commits:

94026d1trac #28382: fix compilation warnings with cplex backends

comment:2 Changed 22 months ago by dcoudert

  • Cc slabbe added

comment:3 Changed 22 months ago by slabbe

I do not have CPLEX installed. Is there a way to get a free version for research (like Gurobi)?

comment:4 Changed 22 months ago by dcoudert

Go to http://ibm.biz/CPLEXonAI for instructions. You will have to register to the IBM academic initiative. You will then have access to CPLEX optimization studio versions 12.8 and 12.9.

Note that currently Sage is incompatible with CPLEX 12.9. See #27790. So I suggest you to download both, install 12.8, and switch to 12.9 only after #27790 is finalized and merged.

comment:5 Changed 20 months ago by dcoudert

  • Cc vdelecroix added
  • Milestone changed from sage-8.9 to sage-9.0

comment:6 Changed 20 months ago by slabbe

David, I wanted to tell you I am on a rush for grant application until mid October. I won't be able to work on this ticket and the other one before. If Vincent can't work on it now, I will do the review after my rush. Sébastien

comment:7 Changed 19 months ago by slabbe

  • Status changed from needs_review to needs_info

After clicking hundreds of time on the ibm webpage to get to the page where I can download cplex, I manage to install it.

I get much less warnings with the current branch, but still a few :

[sagelib-9.0.beta4] Compiling sage/numerical/backends/cplex_backend.pyx because it depends on sage/numerical/backends/cplex_backend.pxd.
[sagelib-9.0.beta4] [1/1] Cythonizing sage/numerical/backends/cplex_backend.pyx
[sagelib-9.0.beta4] Finished Cythonizing, time: 2.34 seconds.
[sagelib-9.0.beta4] copying ./sage/numerical/backends/cplex_backend.pxd -> build/lib.linux-x86_64-2.7/sage/numerical/backends
[sagelib-9.0.beta4] running build_py
[sagelib-9.0.beta4] copying sage/geometry/polyhedron/base_QQ.py -> build/lib.linux-x86_64-2.7/sage/geometry/polyhedron
[sagelib-9.0.beta4] running build_ext
[sagelib-9.0.beta4] building 'sage.numerical.backends.cplex_backend' extension
[sagelib-9.0.beta4] Executing 1 command (using 1 thread)
[sagelib-9.0.beta4] [1/1] gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -fPIC -I/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/cysignals -I./sage/cpython -Isage/cpython -I/home/slabbe/GitBox/sage/local/include -I/home/slabbe/GitBox/sage/src -I/home/slabbe/GitBox/sage/src/sage/ext -I/home/slabbe/GitBox/sage/local/include/python2.7 -I/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/numpy/core/include -Ibuild/cythonized -I/home/slabbe/GitBox/sage/local/include/python2.7 -c build/cythonized/sage/numerical/backends/cplex_backend.c -o build/temp.linux-x86_64-2.7/build/cythonized/sage/numerical/backends/cplex_backend.o -fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1 -std=c99
[sagelib-9.0.beta4] build/cythonized/sage/numerical/backends/cplex_backend.c: In function ‘__pyx_f_4sage_9numerical_8backends_13cplex_backend_12CPLEXBackend_solver_parameter’:
[sagelib-9.0.beta4] build/cythonized/sage/numerical/backends/cplex_backend.c:14297:7: warning: ‘CPXsetlogfile’ is deprecated [-Wdeprecated-declarations]
[sagelib-9.0.beta4]        __pyx_t_1 = __Pyx_PyInt_From_int(CPXsetlogfile(__pyx_v_self->env, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1605, __pyx_L1_error)
[sagelib-9.0.beta4]        ^
[sagelib-9.0.beta4] In file included from build/cythonized/sage/numerical/backends/cplex_backend.c:643:0:
[sagelib-9.0.beta4] ../local/include/cplex.h:1495:4: note: declared here
[sagelib-9.0.beta4]     CPXsetlogfile (CPXENVptr env, CPXFILEptr lfile);
[sagelib-9.0.beta4]     ^
[sagelib-9.0.beta4] build/cythonized/sage/numerical/backends/cplex_backend.c:14402:7: warning: ‘CPXsetlogfile’ is deprecated [-Wdeprecated-declarations]
[sagelib-9.0.beta4]        __pyx_t_1 = __Pyx_PyInt_From_int(CPXsetlogfile(__pyx_v_self->env, __pyx_v_ff)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1611, __pyx_L1_error)
[sagelib-9.0.beta4]        ^
[sagelib-9.0.beta4] In file included from build/cythonized/sage/numerical/backends/cplex_backend.c:643:0:
[sagelib-9.0.beta4] ../local/include/cplex.h:1495:4: note: declared here
[sagelib-9.0.beta4]     CPXsetlogfile (CPXENVptr env, CPXFILEptr lfile);
[sagelib-9.0.beta4]     ^
[sagelib-9.0.beta4] gcc -pthread -shared -L/home/slabbe/GitBox/sage/local/lib -Wl,-rpath,/home/slabbe/GitBox/sage/local/lib -L/home/slabbe/GitBox/sage/local/lib -Wl,-rpath,/home/slabbe/GitBox/sage/local/lib build/temp.linux-x86_64-2.7/build/cythonized/sage/numerical/backends/cplex_backend.o -L/home/slabbe/GitBox/sage/local/lib -L/home/slabbe/GitBox/sage/local/lib -lcplex -lpython2.7 -o build/lib.linux-x86_64-2.7/sage/numerical/backends/cplex_backend.so -lpari
[sagelib-9.0.beta4] Time to execute 1 command: 3.62 seconds.
[sagelib-9.0.beta4] Total time spent compiling C/C++ extensions: 3.65 seconds.

Do you want to get rid of them as well?

comment:8 Changed 19 months ago by slabbe

  • Reviewers set to Sébastien Labbé

comment:9 Changed 19 months ago by dcoudert

Which version of cplex have you installed ? Currently we are not compatible with 12.9 because CPXsetlogfile has been deprecated in 12.8 and removed from 12.9. See #27790.

Last time I checked, both version where available on ibm webpage.

comment:10 Changed 19 months ago by slabbe

I installed both 12.8 and 12.9 and I set up 12.8 to be used in Sage.

If CPXsetlogfile is deprecated, that may explain the remaining warnings I obtain. Right?

comment:11 Changed 19 months ago by slabbe

Ok, I see the next warnings are dealt in #27790.

comment:12 follow-up: Changed 19 months ago by slabbe

When running:

sage -bt --optional=sage,optional,external src/sage/numerical/backends/cplex_backend.pyx

I get 5 errors:

----------------------------------------------------------------------
sage -t src/sage/numerical/backends/cplex_backend.pyx  # 5 doctests failed
----------------------------------------------------------------------
External software detected for doctesting: cplex

but these errors were already there before the current branch. These should be fixed in another ticket.

I give positive review to this ticket.

comment:13 Changed 19 months ago by slabbe

  • Status changed from needs_info to positive_review

comment:14 in reply to: ↑ 12 Changed 19 months ago by slabbe

I get 5 errors:

I created #28708 for the 5 errors.

comment:15 Changed 19 months ago by dcoudert

Thank you for your help.

comment:16 Changed 19 months ago by vbraun

  • Branch changed from public/numerical/28382_cplex to 94026d1c5f9d0edd7d5885d253ff7d6a8ccc315f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.