Initializing help system before first use

XPRB

  • java.lang.Object
    • com.dashoptimization.XPRB
  • All Implemented Interfaces:
    XOctrl, java.lang.AutoCloseable


    public class XPRB
    extends java.lang.Object
    implements XOctrl, java.lang.AutoCloseable
    This class contains the definition of constants and methods for initialization and general settings of BCL. Instances of this class are best handled by try-with-resources statements:
        try (XPRB bcl = new XPRB()) {
            ...
        }
     
    • Constructor Detail

      • XPRB

        public XPRB()
             throws XPRBlicenseError
        Generate an XPRB object and initialize BCL. This method must be called first in order to use the library. In applications that create a large number of problems it is recommended to call the initialization once only per process for highest efficiency. The initialization of BCL Java does not initialize the Java interface of Xpress-Optimizer. If direct access to the Optimizer is required, this interface needs to be initialized by a separate call to XPRS.init.
        Throws:
        XPRBlicenseError - If no valid license is available.
    • Method Detail

      • license

        public static XPRBlicense license(java.lang.String path)
        Generate a license object. This method initiates the OEM licensing procedure.
        Parameters:
        path - path to the license file (may be null)
        Returns:
        A new license object.
        See Also:
        license(XPRBlicense lic)
      • setMsgLevel

        public static void setMsgLevel(int level)
        Set the message print level. BCL can produce different types of messages; status information, warnings and errors. This method controls which of these are output. In case of an error, an exception is raised before any message is output by BCL. The text and numbers of errors can be obtained with methods XPRBerror.getMessage() and XPRBerror.getErrorCode() respectively (the same methods apply to XPRBlicenseError).
             XPRB.setMsgLevel(0);
         
        Parameters:
        level - message level (= types of messages printed by BCL). Possible values:
        • 0 disable all output from BCL and Xpress-Optimizer
        • 2 print warnings
        • 3 print warnings and Optimizer log (default)
        • 4 all messages printed
      • setOutputStream

        public static void setOutputStream(java.lang.Object stream)
        Set the output stream object. BCL uses this object whenever it needs to display text (information, warning or error messages). The provided object must implement either a 'void write(String)' method (like in a Writer class) or a 'void print(String)' method (like in a printStream class). Each problem may have its own stream set using the corresponding method in the XPRBprob object.
             XPRB.setOutputStream(System.err);
         
        Parameters:
        stream - an object implementing either a 'write' or 'print' method
        See Also:
        XPRBprob.setOutputStream(java.lang.Object)
      • setRealFmt

        public static void setRealFmt(java.lang.String fmt)
        Set the format for printing real numbers. In problems with very large or very small numbers it may become necessary to change the printing format to obtain a more exact output. In particular, by changing the precision it is possible to reduce the difference between matrices loaded in memory into Xpress-Optimizer and the output produced by exporting them to a file.
             XPRB.setRealFmt("%.10f");
         
        Parameters:
        fmt - format string (as used by the C function printf). Possible values include:
        • "%g" default printing format (precision: 6 digits; exponential notation if the exponent resulting from the conversion is less than -4 or greater than or equal to the precision)
        • "%.numf print real numbers in the style [-]d.d where the number of digits after the decimal point is equal to the given precision num
      • setColOrder

        public static void setColOrder(int num)
        Set a column ordering criterion for matrix generation. BCL runs reproduce always the same matrix for a problem. This method allows the user to choose a different ordering criterion than the default one.
             XPRB.setColOrder(1);
         
        Parameters:
        num - ordering criterion. Possible values:
        • 0 default order
        • 1 alphabetical order
      • getVersion

        public static java.lang.String getVersion()
        Get the version number of BCL. This information is required if the user is reporting a problem.
             String version;
             version = XPRB.getVersion();
             System.out.println("BCL version number:" + version);
         
        Returns:
        BCL version number
      • newProb

        public XPRBprob newProb(java.lang.String name)
        Create and initialize a new problem. The name given to a problem determines the name and the location of the working files of Xpress-Optimizer. At the creation of a problem any existing working files of the same name are deleted. When solving several instances of a problem simultaneously the user must make sure to assign a different name to every instance. If no problem name is indicated, BCL creates a unique name including the full path to the temporary directory (Xpress-Optimizer creates its working files in the temporary directory).
             try (XPRB bcl = new XPRB()) {
               try (XPRBprob expl2 = bcl.newProb("example2") {
                 ...
               }
             }
         
        Please see also the XPRBprob(String) constructor that provides an easier way to create a problem instance in case you only need one instance.
        Parameters:
        name - problem name, may be null
        See Also:
        XPRBprob(String)
      • getTime

        @Deprecated
        public static int getTime()
        Deprecated.  As of version 8.14, use System.currentTimeMillis().
        Get the running time.
             int starttime;
             starttime = XPRB.getTime();
             System.out.println("Current run time:" +
                 (XPRB.getTime()-starttime)/1000 + "seconds");
         
        Returns:
        time measure in milliseconds
      • beginLicensing

        @Deprecated
        public static boolean beginLicensing()
        Deprecated.  Due to an issue in how this function behaved before Xpress 8.11, it is recommended that you use XPRS.beginLicensing() instead.
        Begin the OEM licensing process.
        Returns:
        true if no license has been obtained yet
      • endLicensing

        @Deprecated
        public static void endLicensing()
        Deprecated.  Use XPRS.endLicensing() instead.
        End the OEM licensing process.
      • close

        public void close()
        Release native resources acquired by BCL. If this method is called explicitly from the user's program to force the finalization of BCL (releasing the license) any problems created by the program must have been finalized (see XPRBprob.close()) previously and the program must not access any BCL objects after this call. It is recommended to use this function only implicitly via try-with-resources:
             try (XPRB bcl = new XPRB()) {                       // Initialize BCL
               try (XPRBprob expl2 = bcl.newProb("example2"));   // Create a problem
                 ...
               }                                                 // Release problem
             }                                                   // Finalize BCL (release license)
         
        Specified by:
        close in interface  java.lang.AutoCloseable
        Since:
        8.14
      • finalize

        @Deprecated
        public void finalize()
        Deprecated.  As of version 8.14, use close(), or, even better, use try-with-resources.
        Overrides:
        finalize in class  java.lang.Object
      • disableFinalizers

        public static void disableFinalizers()
        Prevent BCL finalizers from calling native code. Some finalizers for BCL classes call native code. This is a problem in some situations and can lead to crashes, for example on JVM shutdown. Calling this function disables these calls into native code. Disabling these native calls also means that native memory may not be released which in turn can lead to memory leaks. So finalizers should be disabled in case the JVM is shutting down anyway. Note that the preferred way to avoid these crashes is to use try-with-resources for any BCL object that implements the AutoCloseable interface or to explicitly close() these objects when they are no longer needed.
      • isFinalizersDisabled

        public static boolean isFinalizersDisabled()

© 2001-2024 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.