Initializing help system before first use

XPRS

  • java.lang.Object
    • com.dashoptimization.XPRS
    • Constructor Detail

      • XPRS

        public XPRS​(java.lang.String path)
        Create a new instance. This constructor only exists so that you can use initialization and cleanup within try-with-resources:
           try (XPRS xprs = new XPRS("...")) { // equivalent to XPRS.init("...")
             ...
           }                                   // equivalent to XPRS.free()
         
        The constructor calls init(String) with path and the close function will call free(). So above code is equivalent to
         XPRS.init(path);
         try {
             ...
         }
         finally {
             XPRS.free();
         }
         
        Parameters:
        path - The path for licensing. This is passed to init(String). Can be null to indicate the default license location.
        Since:
        8.14
      • XPRS

        public XPRS()
        Shortcut for XPRS(String) with a null path.
        Since:
        8.14
    • Method Detail

      • isInitialized

        public static boolean isInitialized()
        Check if init(String) or init() were called successfully and free() was not called yet.
        Returns:
        true if Xpress is initialized, false otherwise.
      • close

        public void close()
        Call free(). This function supports license management via try-with-resources:
           try (XPRS xprs = new XPRS()) {  // acquire a license
               ...
           }                               // implicitly release license (even in case of exceptions)
         
        Specified by:
        close in interface  java.lang.AutoCloseable
        Since:
        8.14
      • init

        public static void init​(java.lang.String path)
                         throws XPRSexception
        Initialize Xpress.
        Parameters:
        path - Path to license location.
        Throws:
        XPRSexception
        See Also:
        init(), free()
      • getLicErrMsg

        public static java.lang.String getLicErrMsg()
                                             throws XPRSexception
        Get the last license error message.
        Returns:
        The error message for the last licensing error encountered.
        Throws:
        XPRSexception
      • startRecord

        public static void startRecord​(java.lang.String path,
                                       java.lang.String cfgFilePath,
                                       int flags)
                                throws XPRSexception
        Throws:
        XPRSexception
      • setCheckedMode

        public static void setCheckedMode​(boolean checkedmode)
                                   throws XPRSexception
        You can use this function to disable some of the checking and validation of function calls and function call parameters for calls to the Xpress Optimizer API. This checking is relatively lightweight but disabling it can improve performance in cases where non-intensive Xpress Optimizer functions are called repeatedly in a short space of time. Please note: after disabling function call checking and validation, invalid usage of Xpress Optimizer functions may not be detected and may cause the Xpress Optimizer process to behave unexpectedly or crash. It is not recommended that you disable function call checking and validation during application development.
        Parameters:
        checkedmode - Pass as 0 to disable much of the validation for all Xpress function calls from the current process. Pass 1 to re-enable validation. By default, validation is enabled.
        Throws:
        XPRSexception
      • getCheckedMode

        public static void getCheckedMode​(BoolHolder p_checkedmode)
                                   throws XPRSexception
        You can use this function to interrogate whether checking and validation of all Optimizer function calls is enabled for the current process. Checking and validation is enabled by default but can be disabled by setCheckedMode.
        Parameters:
        p_checkedmode - Variable that is set to 0 if checking and validation of Optimizer function calls is disabled for the current process, non-zero otherwise.
        Throws:
        XPRSexception
      • getBanner

        public static void getBanner​(StringHolder banner)
                              throws XPRSexception
        Returns the banner and copyright message.
        Parameters:
        banner - A buffer of at least XPRS_MAXBANNERLENGTH characters in which the null terminated banner string will be returned.
        Throws:
        XPRSexception
      • getVersion

        public static void getVersion​(StringHolder version)
                               throws XPRSexception
        Returns the full Optimizer version number in the form 15.10.03, where 15 is the major release, 10 is the minor release, and 03 is the build number.
        Parameters:
        version - Buffer long enough to hold the version string (plus a null terminator). This should be at least 16 characters.
        Throws:
        XPRSexception
      • getVersionNumbers

        public static void getVersionNumbers​(IntHolder p_major,
                                             IntHolder p_minor,
                                             IntHolder p_build)
                                      throws XPRSexception
        Returns the Optimizer version numbers split into major, minor, and build number.
        Parameters:
        p_major - Pointer to integer to receive the major version number. Can be null.
        p_minor - Pointer to integer to receive the minor version number. This is a number from 0 to 99. Can be null.
        p_build - Pointer to integer to receive the build number. This is a number from 0 to 99. Can be null.
        Throws:
        XPRSexception
      • getDaysLeft

        public static void getDaysLeft​(IntHolder p_daysleft)
                                throws XPRSexception
        Returns the number of days left until the license expires.
        Parameters:
        p_daysleft - Pointer to an integer where the number of days is to be returned. For a permanent license, the return value will be XPRS_MAXINT
        Throws:
        XPRSexception
      • featureQuery

        public static void featureQuery​(java.lang.String feature,
                                        IntHolder p_status)
                                 throws XPRSexception
        Checks if the provided feature is available in the current license used by the optimizer.
        Parameters:
        feature - The feature string to be checked in the license.
        p_status - Return status of the check, a value of 1 indicates the feature is available.
        Throws:
        XPRSexception
      • setArchConsistency

        public static void setArchConsistency​(int consistent)
                                       throws XPRSexception
        Sets whether to force the same execution path on various CPU architecture extensions, in particular (pre-)AVX and AVX2.
        Parameters:
        consistent - Whether to force the same execution path:
        • 0: Do not force the same execution path (default behavior);
        • 1: Force the same execution path.
        Throws:
        XPRSexception
      • getLastError

        public static java.lang.String getLastError()
                                             throws XPRSexception
        Returns the last error encountered during a call to the Xpress global environment.
        Returns:
        The requested information.
        Throws:
        XPRSexception
      • getLastError

        public static java.lang.String getLastError​(IntHolder p_msgcode)
                                             throws XPRSexception
        Returns the last error encountered during a call to the Xpress global environment.
        Parameters:
        p_msgcode - Memory location in which the error code will be returned. Can be null if not required.
        Returns:
        The requested information.
        Throws:
        XPRSexception
      • setComputeAllowed

        public static void setComputeAllowed​(XPRSenumerations.AllowCompute allow)
                                      throws XPRSexception
        Set whether the current application is allowed to use the Insight Compute interface.
        Parameters:
        allow - Whether the Insight Compute interface may be used; must be one of the following constants:
        • XPRS_ALLOW_COMPUTE_ALWAYS: Always allow solves to be sent to Compute.
        • XPRS_ALLOW_COMPUTE_NEVER: Never allow solves to be sent to Compute.
        • XPRS_ALLOW_COMPUTE_DEFAULT: Allow solves to be sent to Compute only from non-OEM applications.
        Throws:
        XPRSexception
      • getComputeAllowed

        public static XPRSenumerations.AllowCompute getComputeAllowed()
                                                               throws XPRSexception
        Query whether the current application is allowed to use the Insight Compute interface.
        Returns:
        Value will equal one of the following constants.
        • XPRS_ALLOW_COMPUTE_ALWAYS: Always allow solves to be sent to Compute.
        • XPRS_ALLOW_COMPUTE_NEVER: Never allow solves to be sent to Compute.
        • XPRS_ALLOW_COMPUTE_DEFAULT: Allow solves to be sent to Compute only from non-OEM applications.
        Throws:
        XPRSexception
      • addMsgHandlerListener

        public static void addMsgHandlerListener​(XPRSmsgHandlerListener listener)
                                          throws XPRSexception
        Set the listener for the MsgHandlercallback. Note that the global environment can have at most one MsgHandler listener.
        Parameters:
        listener - The listener to which the event will be dispatched.
        Throws:
        XPRSexception
      • addMsgHandlerListener

        public static void addMsgHandlerListener​(XPRSmsgHandlerListener listener,
                                                 java.lang.Object data)
                                          throws XPRSexception
        Set the listener for the MsgHandlercallback. Note that the global environment can have at most one MsgHandler listener.
        Parameters:
        listener - The listener to which the event will be dispatched.
        data - An additional object which will be passed down to the callback function
        Throws:
        XPRSexception
      • removeMsgHandlerListener

        public static void removeMsgHandlerListener()
                                             throws XPRSexception
        Remove the listener for the MsgHandlercallback.
        Throws:
        XPRSexception
      • addMsgHandlerListener

        public static void addMsgHandlerListener​(java.io.Writer w)
                                          throws XPRSexception
        Allow messages to be redirected to a Writer.
        Parameters:
        w - Writer to which messages are redirected.
        Throws:
        XPRSexception
      • addMsgHandlerListener

        public static void addMsgHandlerListener​(java.io.OutputStream w)
                                          throws XPRSexception
        Allow messages to be redirected to an OutputStream.
        Parameters:
        w - Stream to which messages are redirected.
        Throws:
        XPRSexception

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.