Forum Discussion

FICO's avatar
FICO
Community Manager
3 years ago

XPRSmipoptimize - received signal SIGFPE, Arithmetic exception.

I am working on a program written in Pascal that's failing to optimize a MIP problem using XPRESS. The problem is created with XPRSloadmip and optimized with XPRSmipoptimize.

In order to debug this issue, I have written the problem to file (right before the call to XPRSmipoptimize) using XPRSwriteprob and not only the values are being correctly loaded, but the problem itself has a solution (tested with IVE > Optimizer > Optimize matrix file...).

I set XPRSsetlogfile to write to a log file, which contains the following text:

 
Reading Problem MipSimplex
Problem Statistics
          32 (      0 spare) rows
         158 (      0 spare) structural columns
         242 (      0 spare) non-zero elements
MIP Entity Statistics
           5 entities        0 sets        0 set members
FICO Xpress v9.0.2, Hyper, solve started 11:59:27, Mar 29, 2023
Heap usage: 152KB (peak 184KB, 121KB system)
Maximizing MILP MipSimplex using 1 thread and up to 125GB memory, with default controls
Original problem has:
        32 rows          158 cols          242 elements         5 entities

The error is the following (GDB "where"):

Thread 2 "cmdopt_xprs" received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x7ffff1b0e700 (LWP 1312619)]
0x00007ffff454a185 in ?? () from /opt/xpressmp/lib/libxprs.so.41
(gdb) where
#0  0x00007ffff454a185 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#1  0x00007ffff4547086 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#2  0x00007ffff60a8e85 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#3  0x00007ffff6088f40 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#4  0x00007ffff60877f0 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#5  0x00007ffff556d4e9 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#6  0x00007ffff50036b2 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#7  0x00007ffff555efb0 in ?? () from /opt/xpressmp/lib/libxprs.so.41
#8  0x00007ffff555f4cd in ?? () from /opt/xpressmp/lib/libxprs.so.41
#9  0x00007ffff555fdd1 in XPRSmaxim_internal () from /opt/xpressmp/lib/libxprs.so.41
#10 0x00007ffff555f7bd in XPRSmipoptimize_internal () from /opt/xpressmp/lib/libxprs.so.41
#11 0x00007ffff48a711d in XPRSmipoptimize () from /opt/xpressmp/lib/libxprs.so.41

XPRSloadmip, XPRSchgobjsense and XPRSmipoptimize return 0, so no error is detected in those steps.

I am using the following interface that was generated by h2pas:

  function XPRScreateprob(_probholder:PXPRSprob):longint;cdecl;external External_library name 'XPRScreateprob';
 
  function XPRSdestroyprob(_prob:XPRSprob):longint;cdecl;external External_library name 'XPRSdestroyprob';
 
  function XPRSinit(path:Pchar):longint;cdecl;external External_library name 'XPRSinit';
                                                                                                    
...

10 Replies

  • FICO's avatar
    FICO
    Community Manager

    I would like to add that the version of XPRESS that I am running was installed from xp9.0.2_linux_x86_64_setup.tar

  • FICO's avatar
    FICO
    Community Manager

    Just to clariy: the problem only occurs when you solve from your program? If you solve the exported model file with the console optimizer then there is no exception?

    Can you share the exported model file? If you don't want to share it here, you may send it to danieljunglas(at)fico(dot)com. If the variable/constraint names contain sensitive information, you may scramble these names by passing option `s` to XPRSwriteprob().

  • FICO's avatar
    FICO
    Community Manager

    The problem occurs only from the program, IVE on Windows seems to solve just fine. The console optimizer on the same machine does however not run because of a missing library libncurses.so.5 (libncurses.so.6 is installed). This is a recent XPRESS upgrade as 8.5 was previously installed.

    $ file /opt/xpressmp/bin/optimizer
     
    /opt/xpressmp/bin/optimizer: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=cbe6d2c2dd85a0ed171495954b8cec9b1f20c54a, stripped

    And this is the beginning of xphostid

    $ /opt/xpressmp/bin/xphostid
     
    == FICO Xpress host ID tool ==
     
    == (c) Fair Isaac Corporation 2005-2022. All rights reserved ==
     
    When applying for a license you must send the entire text printed below to your vendor:
     
     
     
    <xphostid version="3.2.5" xpress="9.0" build="linux_x86_64">

    I attached the relevant matrix file.

    Thank you very much.

    Also, in my original message, when I said:

    "XPRSloadmip, XPRSchgobjsense and XPRSmipoptimize return 0, so no error is detected in those steps."

    I meant:

    XPRSloadmip, XPRSchgobjsense and XPRSwriteprob return 0, so no error is detected in those steps.

    XPRSmipoptimize never actually returns anything as the function call does not complete and is interrupted by the exception mentioned in my message.

  • FICO's avatar
    FICO
    Community Manager

    Well, I linked the missing .so's, so that it references the .so.6 when attempting to load the .so.5 both for libncurses.so.5 and libtinfo.so.5 and now the optimizer command works.

    This is the output:

    [xpress jpsierra] readprob /tmp/problema_antes_mipoptimize.mps.lp
     
    Reading Problem problema_antes_mipoptimize.mps
    Problem Statistics
              32 (      0 spare) rows
             158 (      0 spare) structural columns
             242 (      0 spare) non-zero elements
    MIP Entity Statistics
               5 entities        0 sets        0 set members
    [xpress jpsierra] mipoptimize
    FICO Xpress v9.0.2, Hyper, solve started 9:03:26, Mar 30, 2023
    Heap usage: 409KB (peak 601KB, 130KB system)
    Maximizing MILP problema_antes_mipoptimize.mps using 1 thread and up to 125GB memory, with default controls
    Original problem has:
            32 rows          158 cols          242 elements         5 entities
    Presolved problem has:
            25 rows           85 cols          145 elements         5 entities
    LP relaxation tightened
    Presolve finished in 0 seconds
    Heap usage: 461KB (peak 601KB, 130KB system)
     
    Coefficient range                    original                 solved
      Coefficients   [min,max] : [ 1.34e-02,  1.43e+02] / [ 6.25e-02,  2.00e+00]
      RHS and bounds [min,max] : [ 4.37e-10,  8.21e+07] / [ 1.66e-09,  4.12e+02]
      Objective      [min,max] : [ 1.00e-02,  4.36e+05] / [ 3.20e+00,  1.45e+06]
    Autoscaling applied standard scaling
     
    Will try to keep branch and bound tree memory usage below 118.9GB
     
       Its         Obj Value      S   Ninf  Nneg   Sum Dual Inf  Time
         0       1240117.979      D     11     0        .000000     0
        25      -4868744.855      D      0     0        .000000     0
    Optimal solution found
    Dual solved problem
      25 simplex iterations in 0.00 seconds at time 0
     
    Final objective                       : -4.868744854550569e+06
      Max primal violation      (abs/rel) :       0.0 /       0.0
      Max dual violation        (abs/rel) :       0.0 /       0.0
      Max complementarity viol. (abs/rel) :       0.0 /       0.0
     
    Starting root cutting & heuristics
     
     Its Type    BestSoln    BestBound   Sols    Add    Del     Gap     GInf   Time
    c        -4951199.318 -4868744.855      1                  1.67%       0      0
    d        -4947818.410 -4868744.855      2                  1.60%       0      0
       1  K  -4947818.410 -4946084.252      2     27      0    0.04%       5      0
     *** Search completed ***
    Uncrunching matrix
    Final MIP objective                   : -4.947818410385440e+06
    Final MIP bound                       : -4.947813541640585e+06
      Solution time / primaldual integral :      0.00s/ 68.381709%
      Number of solutions found / nodes   :         2 /         1
      Max primal violation      (abs/rel) : 1.990e-13 / 2.842e-14
      Max integer violation     (abs    ) :       0.0
  • FICO's avatar
    FICO
    Community Manager

    By default the console optimizer runs with floating point exceptions disabled, this is probably why you don't get an exception there.

    Could you try to explicitly disable floating point exceptions in your Pascal program? You would have to do something equivalent to feenableexcept(), see for example here.

    If this fixes the problem, you could try to figure out which of the exceptions is thrown (inexact, invalid, overflow, underflow, divbyzero) and then potentially only disable that exception.

    So far I have only been able to produce an "inexact" exception here with your model and that exception is expected in certain places.

  • FICO's avatar
    FICO
    Community Manager

    I'm trying to do what you suggested, I'll keep you updated. Thank you.

  • FICO's avatar
    FICO
    Community Manager

    With this line it still crashes:

    SetExceptionMask(GetExceptionMask + [exZeroDivide]);

    But with this one, it does not:

    SetExceptionMask(GetExceptionMask + [exZeroDivide,exInvalidOp]);

    So apparently it's the invalidOp that's causing the problem.

    Took the code from this page

  • FICO's avatar
    FICO
    Community Manager

    I managed to reproduce the "invalid operation" exception here. We are investigating. For the moment, the only workaround I see is to mask that exception :-(

  • FICO's avatar
    FICO
    Community Manager

    I found the problem. It was an invalid floating point speculation. This will be fixed in the next release. Until then it is safe to ignore the exception.