Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

xpress.InterfaceError: Incorrect control name error

I upgraded FICO Xpress Optimization from version 8.8.0 to 8.9.3. The following used to work in the python3 interface of version 8.8.0:

import xpress as xp
xp.controls.outputlog = 0  # disable all solver output
xp.controls.maxtime = -1800  # time limit in seconds, negative for "stop even if no solution is found"

After the update to 8.9.3, this now results in the following error:

Traceback (most recent call last):
 ...
 File "transfers/src/scse/modules/placement/sfc_transfers_lp.py", line 104, in _compute_transfers
  xp.controls.outputlog = 0
xpress.InterfaceError: Incorrect control name

According to the manual and the reference manual this is still supposed to work?

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    Hi Joris,

    My guess is that Xpress is picking up an OEM license. In this case, the Python interface cannot read the control names until Xpress has been initialized by calling the xp.license() function. I assume you are using Linux, in which case, please check that the XPRESS environment variable is pointing to the license file that you want to use. Note that Xpress might also look for a license file at /opt/xpressmp/bin/xpauth.xpr, so I suggest you check this too.

    Regards,

    Chris

  • FICO's avatar
    FICO
    Community Manager

    Hi Chris, it seems you are correct. I'm indeed using an OEM license with linux, and the XPRESS environment variable points to the OEM license file.

    import xpress as xp
    oemnum = hidden
    string= ""
    n,string = xp.license(0,string)
    lic = oemnum - n*n//19
    n,string = xp.license(lic,string)
     
    xp.controls.outputlog = 0
     
    S = range(5)          # that's the set {0,1,2,3,4}
    value = [102, 512, 218, 332, 41]  # or just read them from file
    weight = [21, 98, 44, 59, 9]
     
    x = [xp.var(vartype=xp.binary) for i in S]
    profit = xp.Sum(value[i] * x[i] for i in S)
     
    p = xp.problem("knapsack")
    p.addVariable(x)
    p.addConstraint(xp.Sum(weight[i] * x[i] for i in S) <= 130)
    p.setObjective(profit, sense=xp.maximize)
     
    p.solve()

    The code snippet above didn't work and produced the aforementioned error. However, replacing lines 3-6 with:

    if (xp.beginlicensing()):
        string = ""
        n,string = xp.license(0,string)
        lic = oemnum - n*n//19
        n,string = xp.license(lic,string)
        xp.init()
        xp.endlicensing()

    solved the problem.

    Also note that, the first code block works fine if line 8 is commented out. This is very confusing and should probably throw a more descriptive error than 'xpress.InterfaceError: Incorrect control name', i.e. some error that points to the licensing issue.