Forum Discussion

FICO's avatar
FICO
Community Manager
4 years ago

Optimizer controls in Python

Could you please point to a reference of the solver controls that can be set from Python API (package xpress)? It seems that the names are not the same as in Mosel (e.g., XPRS_MIPRELSTOP and XPRS_VERBOSE) but I cannot find a list in the documentation.

Thank you,

Miroslav

5 Replies

  • FICO's avatar
    FICO
    Community Manager

    The reference documentation for xpress.problem.setControl() says:

    setControl(...)
        Purpose: 
        Sets one or more controls of a problem.
        
        Synopsis:
        
        problem.setControl(string, value)
        
        Example: 
        p = xpress.problem()
        p.setControl('miprelstop', 1e-4)
        p.setControl({'feastol': 1e-4, 'presolve': 0})
        
        Further information:
        ...
        2.  
        This function can be used in two ways depending on whether one wants
        to set one or more controls. In the first case, the arguments form a
        pair (string, value) where the first element is the lower-case name of
        a control (see the Xpress Optimizer reference manual for a complete
        list of controls). In the second case, the argument is a Python
        dictionary whose keys are control name string and whose values
        are the value of the control.

    So the names of controls used in the Python interface are the lower-case names (without the XPRS_ prefix).

    The same naming convention applies when referring to controls as object members.

    This is explained in the user manual here and here.

  • FICO's avatar
    FICO
    Community Manager

    Thank you, Daniel!

    Slightly unrelated... Is there a control that suppresses _all_ log messages from the solvers?

  • FICO's avatar
    FICO
    Community Manager

    Also, the statement that removing "XPRS_" and switching to lowercase does the job doesn't seem to be correct. The statement:

    model.setControl('verbose',False)

    returns an error: 

    InterfaceError: Incorrect control name

  • FICO's avatar
    FICO
    Community Manager

    The function to globally disable Xpress output in Python is xpress.setOutputEnabled(False). "verbose" is not a public solver control. XPRS_VERBOSE is a convenience thing only defined in Mosel.

  • FICO's avatar
    FICO
    Community Manager

    Thank you, Daniel! This helps.