Initializing help system before first use

XPRBprob

  • java.lang.Object
    • com.dashoptimization.XPRBprob
  • All Implemented Interfaces:
    java.lang.AutoCloseable


    public class XPRBprob
    extends java.lang.Object
    implements java.lang.AutoCloseable
    This class represents a problem definition in BCL.
    • Constructor Detail

      • XPRBprob

        public XPRBprob(java.lang.String name)
        Create a new BCL problem instance. This function is similar to XPRB.newProb(String) but does not need an XPRB instance. It will implicitly create the required XPRB instance and release that instance when the close() function is called. With this function you can easily create new problems and manage the related native resources like so:
            try (XPRBprob prob = new XPRBprob("problem")) {
                ... // Use the problem here
            } // Resources will be automatically cleaned up here.
         
        Since:
        8.14
    • Method Detail

      • isValid

        public boolean isValid()
        Test whether a problem is correctly defined.
             XPRBprob expl2;
             if(expl2.isValid() == false)
                System.out.println("Error in problem definition.");
         
      • reset

        public void reset()
        Reset the problem. This method deletes any solution information stored in BCL; it also deletes the corresponding Optimizer problem and removes any auxiliary files that may have been created by optimization runs. The problem definition itself remains. This method may be used to free up memory if the solution information is not required any longer but the problem definition is to be kept for later (re)use.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.mipOptimize();
                 expl2.reset();
             }
         
      • setMsgLevel

        public 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.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.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 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).
             prob.setOutputStream(System.err);
         
        Parameters:
        stream - an object implementing either a 'write' or 'print' method
      • setRealFmt

        public 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.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.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 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.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setColOrder(1);
             }
         
        Parameters:
        num - ordering criterion. Possible values:
        • 0 default order
        • 1 alphabetical order
      • newVar

        public XPRBvar newVar(java.lang.String name,
                              int type,
                              double lob,
                              double upb)
        Create a variable. The creation of a variable in BCL involves not only its name but also its type and bounds (which may be infinite, defined by the corresponding Xpress constants). If the indicated name is already in use, BCL adds an index to it. If no variable name is given, BCL generates a default name starting with VAR. (The generation of unique names will only take place if the names dictionary is enabled, see setDictionarySize(int, int)). If a partial integer, semi-continuous, or semi-continuous integer variable is being created, the integer or semi-continuous limit (= lower bound of the continuous part for partial integer and semi-continuous, and of the semi-continuous integer part for semi-continuous integer) is set to the maximum of 1 and bdl. This value can be subsequently modified with the method XPRBvar.setLim(double).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
                 XPRBvar x2 = expl2.newVar("efg2", XPRB.SC, 0, 20);     // x2=0 or 1<=x2<=20
             }
         
        Parameters:
        type - variable type. Possible values:
        • XPRB.PL continuous (default)
        • XPRB.BV binary
        • XPRB.UI general integer
        • XPRB.PI partial integer
        • XPRB.SC semi-continuous
        • XPRB.SI semi-continuous integer
        name - variable name, may be null
        lob - lower bound, may be -XPRB.INFINITY for minus infinity (default 0)
        upb - upper bound, may be XPRB.INFINITY for plus infinity (default XPRB.INFINITY)
        Returns:
        A new variable of type XPRBvar
      • newCtr

        public XPRBctr newCtr(java.lang.String name,
                              XPRBrelation lr)
        Create a new constraint. This method has to be called before XPRBctr.addTerm(com.dashoptimization.XPRBvar, double) or XPRBctr.setTerm(com.dashoptimization.XPRBvar, double) are used to add terms to the constraint. Range constraints can first be created with any type and then converted using the function XPRBctr.setRange(double, double). If the indicated name is already in use, BCL adds an index to it. If no constraint name is given, BCL generates a default name starting with CTR . (The generation of unique names will only take place if the names dictionary is enabled, see setDictionarySize(int, int)).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x2 = expl2.newVar("x2");
                 XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
             }
         
        Parameters:
        name - constraint name, may be null (default)
        lr - linear relation (default 0-valued, non-binding relation)
        Returns:
        A new constraint of type XPRBctr
      • delCtr

        public void delCtr(XPRBctr ctr)
        Delete a constraint. If this constraint has previously been selected as the objective function (using method setObj(com.dashoptimization.XPRBctr)), the objective will be set to null. If the constraint occurs in a previously saved basis that is to be (re)loaded later on you should change its type to XPRB.N using XPRBctr.setType(int) instead of entirely deleting the constraint.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x2 = expl2.newVar("x2");
                 XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
                 expl2.delCtr(ctr1);
             }
         
        Parameters:
        ctr - constraint of type XPRBctr
      • setObj

        public void setObj(XPRBctr ctr)
        Select the objective function. The variable terms of the indicated constraint become the objective function. The objective function must be set before any optimization task is carried out. Typically, the objective constraint will have the type XPRB.N, but any other type of constraint may be chosen too. In the latter case, the equation or inequality expressed by the constraint also remains part of the problem. Changes to the constraint after setting the objective function will also modify the latter.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar[] x = new XPRBvar[5];
                 for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
                 XPRBctr ctr3 = expl2.newCtr("r3", x[0].add(x[1]).lEql(10));
                 expl2.setObj(ctr3);
             }
         
        Parameters:
        ctr - constraint of type XPRBctr
      • setObj

        public void setObj(XPRBexpr q)
        Set the objective function. The indicated expression becomes the objective function. Changes to the expression after setting the objective function will have no effect on the latter. The objective function must be set before any optimization task is carried out.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar[] x = new XPRBvar[5];
                 for(int i=0;i<5;i++) x[i] = expl2.newVar("x");
                 XPRBexpr qe = new XPRBexpr();
                 qe.add(x[2].mul(x[3]));
                 expl2.setObj(qe);
             }
         
        Parameters:
        q - expression of type XPRBexpr
      • newSol

        public XPRBsol newSol()
        Create a solution. This method creates a new solution.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x = expl2.newVar("x");
                 XPRBsol sol1 = expl2.newSol();
                 sol1.addVar(x, 1.0);
             }
         
        Returns:
        A new solution
      • newSos

        public XPRBsos newSos(java.lang.String name,
                              int type,
                              XPRBexpr le)
        Create a SOS. This method creates a Special Ordered Set (SOS) of type 1 or 2 (abbreviated SOS1 and SOS2). If a linear expression is given as parameter, the variables in the expression are added to the SOS and the coefficient of each variable becomes its weight. Further set elements may be added (method XPRBsos.addElement(com.dashoptimization.XPRBvar, double)) or deleted (method XPRBsos.delElement(com.dashoptimization.XPRBvar)). If the indicated name is already in use, BCL adds an index to it. If no name is given for the set, BCL generates a default name starting with SOS. (The generation of unique names will only take place if the names dictionary is enabled, see setDictionarySize(int, int)).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar[] x = new XPRBvar[5];
                 for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
                 XPRBexpr l = new XPRBexpr();
                 for (int i=1;i<4;i++) l.add(x[i].mul(i));
                 XPRBsos set1 = expl2.newSos("sos1", XPRB.S1, l);
              }
         
        Parameters:
        name - name of the set
        type - set type. Possible values:
        • XPRB.S1 Special Ordered Set of type 1
        • XPRB.S2 Special Ordered Set of type 2
        le - linear expression
        Returns:
        A new SOS
      • delSol

        public void delSol(XPRBsol sol)
        Delete a solution. This method deletes a solution.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x = expl2.newVar("x");
                 XPRBsol sol1 = expl2.newSol();
                 sol1.addVar(x, 1.0);
                 expl2.delSol(sol1);
             }
         
        Parameters:
        sol - previously created solution
      • delSos

        public void delSos(XPRBsos sos)
        Delete a SOS. This method deletes a SOS without deleting the variables it consists of.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar[] x = new XPRBvar[5];
                 for (int i=0;i<5;i++) x[i] = expl2.newVar("x");
                 XPRBexpr l = new XPRBexpr();
                 for(int i=1;i<4;i++) l.add(x[i].mul(i));
                 XPRBsos set1 = expl2.newSos("sos1", XPRB.S1, l);
                 expl2.delSos(set1);
             }
         
        Parameters:
        sos - previously created SOS of type 1 or 2
      • newIndexSet

        public XPRBindexSet newIndexSet(java.lang.String name,
                                        int maxsize)
        Create a new index set. Note that the indicated size maxsize corresponds to the space allocated initially to the set, but it is increased dynamically if need be. If the indicated set name is already in use, BCL adds an index to it. If no name is given, BCL generates a default name starting with IDX. (The generation of unique names will only take place if the names dictionary is enabled, see setDictionarySize(int, int)).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBindexSet iset = expl2.newIndexSet("Set",100);
             }
         
        Parameters:
        name - name of the index set to be created, may be null
        maxsize - maximum size of the index set (default 0)
        Returns:
        A new index set of type XPRBindexSet
      • saveBasis

        public XPRBbasis saveBasis()
        Save the current basis. This method saves the basis for the current problem in the optimizer by creating a new object of type XPRBbasis. The basis may be re-input using method loadBasis(com.dashoptimization.XPRBbasis).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.lpOptimize("");
                 XPRBbasis bs1 = expl2.saveBasis();
             }
         
        Returns:
        A new basis of type XPRBbasis
      • loadBasis

        public void loadBasis(XPRBbasis bs)
        Load a previously saved basis. This method loads a basis for the current problem in the optimizer. The basis must have been saved using method saveBasis(). It is not possible to load a basis saved for any other problem, even if the problems are similar. This method takes into account that the problem may have been modified since the basis has been stored (addition of variables and constraints is handled - deletion of constraints is not handled: instead of entirely deleting a constraint, change its type to XPRB.N using XPRBctr.setType(int) if you wish to load the basis later on). Note that the problem has to be loaded explicitly (method loadMat()) before the basis is re-input with this method.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.lpOptimize();
                 XPRBbasis bs1 = expl2.saveBasis();
                 XPRBvar x2 = expl2.newVar("x2");
                 XPRBctr ctr1 = expl2.newCtr("r1", x2.gEql(3));
                 expl2.loadMat();
                 expl2.loadBasis(bs1);
             }
         
        Parameters:
        bs - basis of type XPRBbasis
      • clearDir

        public void clearDir()
        Delete all directives. Directives may be set on variables (method XPRBvar.setDir(int, double)) or on SOS (method XPRBsos#setPriority).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.clearDir();
             }
         
      • setSense

        public void setSense(int dir)
        Set the sense of the objective function. The objective sense is set to minimization by default.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setSense(XPRB.MAXIM);
             }
         
        Parameters:
        dir - sense of the objective function. Possible values:
        • XPRB.MAXIM maximize the objective
        • XPRB.MINIM minimize the objective (default)
      • getSense

        public int getSense()
        Get the sense of the objective function. The objective sense (maximization or minimization) is set to minimization by default and may be changed with methods setSense(int), minim(), and maxim().
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 int dir = expl2.getSense();
             }
         
        Returns:
        Sense of the objective function. Possible values:
        • XPRB.MAXIM maximize the objective
        • XPRB.MINIM minimize the objective
        • -1 in case of error
      • getName

        public java.lang.String getName()
        Get the name of a problem.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 String pbname = expl2.getName();
                 System.out.println("Problem name: " + pbname);
             }
         
        Returns:
        Name of the given problem if method executed successfully, null otherwise
      • setName

        public void setName(java.lang.String name)
        Set the name of a problem.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setName("example_two");
                 String pbname = expl2.getName();
                 System.out.println("Problem name: " + pbname);
             }
         
      • exportProb

        public void exportProb(int format)
                        throws java.io.IOException
        Throws:
        java.io.IOException
        See Also:
        exportProb(format, null)
      • exportProb

        public void exportProb(java.lang.String fname)
                        throws java.io.IOException
        Throws:
        java.io.IOException
        See Also:
        exportProb(XPRB.LP, fname)
      • exportProb

        public void exportProb()
                        throws java.io.IOException
        Throws:
        java.io.IOException
        See Also:
        exportProb(XPRB.LP, null)
      • exportProb

        public void exportProb(int format,
                               java.lang.String fname)
                        throws java.io.IOException
        Print problem matrix to a file. This method prints the matrix to a file with an extended LP or extended MPS format. Provided that no extension is given by the user LP files receive the extension .lp. MPS files always receive the extension .mps. This method is not available in the Student Edition. When exporting matrices semi-continuous and semi-continuous integer variables are preprocessed: if a lower bound value greater than 0 is given, then the variable is treated like a continuous (resp. integer) variable. The precision used by BCL for printing real numbers can be changed with setRealFmt(java.lang.String) to obtain more accurate output for very large or very small numbers. For full precision matrix output the user is advised to switch to the Optimizer function XPRSproblem.writeProb, preceded by a call to loadMat().
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.exportProb(XPRB.MPS, "ex2");
             }
         
        Parameters:
        format - matrix output file format. Possible values:
        • XPRB.LP LP file format
        • XPRB.MPS MPS file format
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • fixMIPEntities

        public void fixMIPEntities(boolean ifround)
        Fix all the global entities Fixes all the global entities to the values of the last found MIP solution. This is useful for finding the reduced costs for the continuous variables after the global variables have been fixed to their optimal values.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.mipOptimize();
                 expl2.fixMIPEntities();
                 expl2.lpOptimize();
             }
         
        Parameters:
        ifround - if all global entities should be rounded to the nearest discrete value in the solution before being fixed.
      • writeDir

        public void writeDir()
                      throws java.io.IOException
        Throws:
        java.io.IOException
        See Also:
        writeDir(null)
      • writeDir

        public void writeDir(java.lang.String fname)
                      throws java.io.IOException
        Write directives to a file. This method writes out to a file the directives defined for a problem. The extension .dir is appended to the given file name. When no file name is given, the name of the problem is used. If a file of the given name exists already it is replaced.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.writeDir();
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • loadMat

        public void loadMat()
        Load a problem into Xpress-Optimizer. This method calls the Xpress-Optimizer methods XPRSloadlp, XPRSloadqprob, XPRSloadglobal, or XPRSloadqglobal (see Xpress-Optimizer manual for details) to transform the current BCL problem definition into a matrix in Xpress-Optimizer. Empty rows and columns are deleted before generating the matrix. Semi-continuous (integer) variables are preprocessed: if a lower bound value greater than 0 is given, then the variable is treated like a continuous (resp. integer) variable. Variables that belong to the problem but do not appear in the matrix receive negative column numbers. Usually, it is not necessary to call this method explicitly because BCL automatically does this conversion whenever it is required.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.loadMat();
             }
         
      • lpOptimise

        public void lpOptimise(java.lang.String alg)
        See Also:
        lpOptimize(alg)
      • lpOptimize

        public void lpOptimize(java.lang.String alg)
        Solve as a continuous problem. This method selects and starts the Xpress-Optimizer LP/QP solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "pn". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with method setSense(int). Before solving a problem, the objective function must be selected with setObj(com.dashoptimization.XPRBctr).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setSense(XPRB.MAXIM);
                 expl2.lpOptimize("b");
             }
         
        Parameters:
        alg - choice of the solution algorithm. Possible values:
        • "p" use primal simplex algorithm
        • "d" use dual simplex algorithm
        • "b" use Newton-Barrier algorithm
        • "n" use the network solver
        • "c" continue previously interrupted optimization run
        • "" no parameter: use the default setting
      • mipOptimise

        public void mipOptimise(java.lang.String alg)
        See Also:
        mipOptimize(alg)
      • mipOptimize

        public void mipOptimize(java.lang.String alg)
        Solve as a discrete problem. This method selects and starts the Xpress-Optimizer MIP/MIQP solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "pl". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with method setSense(int). Before solving a problem, the objective function must be selected with setObj(com.dashoptimization.XPRBctr).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setSense(XPRB.MINIM);
                 expl2.mipOptimize("p");
             }
         
        Parameters:
        alg - choice of the solution algorithm. Possible values:
        • "p" use primal simplex algorithm
        • "d" use dual simplex algorithm
        • "b" use Newton-Barrier algorithm
        • "n" use the network solver (for the initial LP)
        • "l" stop after solving the initial continuous relaxation
        • "c" continue previously interrupted optimization run
        • "" no parameter: use the default setting
      • solve

        @Deprecated
        public void solve()
        Deprecated.  Use lpOptimize or mipOptimize
        See Also:
        solve("")
      • solve

        @Deprecated
        public void solve(java.lang.String alg)
        Deprecated.  Use lpOptimize or mipOptimize
        Call Xpress-Optimizer solution algorithm. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. The sense of the optimization (default: minimization) can be changed with method setSense(int). Before solving a problem, the objective function must be selected with setObj(com.dashoptimization.XPRBctr). Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.solve("pg");
             }
         
        Parameters:
        alg - choice of the solution algorithm. Possible values:
        • "p" use primal simplex algorithm
        • "d" use dual simplex algorithm
        • "b" use Newton-Barrier algorithm
        • "l" only solve the (relaxed) linear problem
        • "n" use the network solver (LP only)
        • "g" solve the global (MIP) problem
        • "" no parameter: use the default setting (LP only)
        See Also:
        lpOptimize(String alg), mipOptimize(String alg), setSense(int dir)
      • minim

        @Deprecated
        public void minim()
        Deprecated.  Use lpOptimize or mipOptimize
        See Also:
        minim("")
      • minim

        @Deprecated
        public void minim(java.lang.String alg)
        Deprecated.  Use lpOptimize or mipOptimize
        Minimize a problem. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. Before solving a problem, the objective function must be selected with setObj(com.dashoptimization.XPRBctr). Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.minim("b");
             }
         
        Parameters:
        alg - choice of the solution algorithm. Possible values:
        • "p" use primal simplex algorithm
        • "d" use dual simplex algorithm
        • "b" use Newton-Barrier algorithm
        • "l" only solve the (relaxed) linear problem
        • "n" use the network solver (LP only)
        • "g" solve the global (MIP) problem
        • "" no parameter: use the default setting (LP only)
        See Also:
        lpOptimize(String alg), mipOptimize(String alg), setSense(int dir)
      • maxim

        @Deprecated
        public void maxim()
        Deprecated.  Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimize
        See Also:
        maxim("")
      • maxim

        @Deprecated
        public void maxim(java.lang.String alg)
        Deprecated.  Use setSense(XPRB.MAXIM) and lpOptimize or mipOptimize
        Maximize a problem. This method selects and starts the Xpress-Optimizer solution algorithm. The characters indicating the algorithm choice may be combined where it makes sense, e.g. "dg". If the matrix loaded in Xpress-Optimizer does not correspond to the current problem definition it is regenerated automatically prior to the start of the algorithm. Before solving a problem, the objective function must be selected with setObj(com.dashoptimization.XPRBctr). Note that if you use an incomplete global search you should finish your program with a call to the Xpress-Optimizer method XPRSinitglobal (see Xpress-Optimizer manual for details) in order to remove all search tree information that has been stored. Otherwise you may not be able to re-run your program.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.maxim("b");
             }
         
        Parameters:
        alg - choice of the solution algorithm. Possible values:
        • "p" use primal simplex algorithm
        • "d" use dual simplex algorithm
        • "b" use Newton-Barrier algorithm
        • "l" only solve the (relaxed) linear problem
        • "n" use the network solver (LP only)
        • "g" solve the global (MIP) problem
        • "" no parameter: use the default setting (LP only)
        See Also:
        lpOptimize(String alg), mipOptimize(String alg), setSense(int dir)
      • getProbStat

        public int getProbStat()
        Get the problem status. Note that the BCL problem status uses a bit-encoding contrary to the LP and MIP status values, because several of the states may apply at the same time.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 int status = expl2.getProbStat();
                 if((status&XPRB.MOD)==XPRB.MOD) expl2.lpOptimize();
             }
         
        Returns:
        Bit-encoded BCL status information. Possible values:
        • XPRB.GEN matrix has been generated
        • XPRB.DIR directives added
        • XPRB.MOD problem has been modified
        • XPRB.SOL problem has been solved
      • getLPStat

        public int getLPStat()
        Get the LP status.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.lpOptimize();
                 int status = expl2.getLPStat();
             }
         
        Returns:
        LP-status information. Possible values:
        • 0 problem has not been loaded
        • XPRB.LP_OPTIMAL LP optimal
        • XPRB.LP_INFEAS LP infeasible
        • XPRB.LP_CUTOFF objective value worse than cutoff
        • XPRB.LP_UNFINISHED LP unfinished
        • XPRB.LP_UNBOUNDED LP unbounded
        • XPRB.LP_CUTOFF_IN_DUAL LP cutoff in dual
        • XPRB.LP_UNSOLVED LP problem not solved
        • XPRB.LP_NONCONVEX QP problem is nonconvex
      • getMIPStat

        public int getMIPStat()
        Get the MIP (global) status.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.mipOptimize();
                 int status = expl2.getMIPStat();
             }
         
        Returns:
        Global (MIP) status information. Possible values:
        • XPRB.MIP_NOT_LOADED problem has not been loaded
        • XPRB.MIP_LP_NOT_OPTIMAL LP has not been optimized
        • XPRB.MIP_LP_OPTIMAL LP has been optimized
        • XPRB.MIP_NO_SOL_FOUND global search incomplete, no integer solution found
        • XPRB.MIP_SOLUTION global search incomplete, an integer solution has been found
        • XPRB.MIP_INFEAS global search complete, no integer solution found
        • XPRB.MIP_OPTIMAL global search complete, an integer solution has been found
        • XPRB.MIP_UNBOUNDED LP unbounded
      • sync

        public void sync(int synctype)
        Synchronize BCL with the Optimizer. This method resets the BCL problem status. XPRB.XPRS_SOL: at the next solution access the solution information in BCL is updated with the solution held in the Optimizer (after MIP search: best integer solution, otherwise solution of the last LP solved). XPRB.XPRS_PROB: at the next call to optimization or loadMat() the problem is completely reloaded into the Optimizer; bound changes are not passed on to the problem loaded in the Optimizer any longer.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.sync(XPRB.XPRS_PROB);
             }
         
        Parameters:
        synctype - type of synchronization. Possible values:
        • XPRB.XPRS_SOL update the BCL solution information with the LP solution currently held in the Optimizer
        • XPRB.XPRS_SOLMIP update the BCL solution information with the MIP solution currently held in the Optimizer
        • XPRB.XPRS_PROB force problem reloading
      • beginCB

        public void beginCB(com.dashoptimization.XPRSprob optprob)
        Start working with BCL within an Optimizer callback. This method precedes any call to BCL functionality within an Optimizer callback. It updates the BCL problem information for working with the local Optimizer subproblem and resets the BCL problem status. This method blocks access to the BCL problem until it is released by a matching call to endCB().
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.beginCB(mylocaloptprob);
                 expl2.sync(XPRB.XPRS_PROB);
                 expl2.endCB();
             }
         
        Parameters:
        optprob - Xpress-Optimizer problem
      • endCB

        public void endCB()
        Terminate working with BCL within an Optimizer callback. This method sets the BCL problem information back to working with the main Optimizer problem, this includes resetting the BCL problem status. There must be a matching call to beginCB(com.dashoptimization.XPRSprob).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.beginCB(mylocaloptprob);
                 expl2.sync(XPRB.XPRS_PROB);
                 expl2.endCB();
             }
         
      • loadMIPSol

        public int loadMIPSol(double[] sol,
                              boolean ifopt)
        Load an integer solution into BCL or the Optimizer. This method loads a MIP solution from an external source (e.g., the Xpress MIP Solution Pool) into BCL or the Optimizer. The solution is given in the form of an array, indexed by the column numbers of the decision variables. The size of the array must correspond to the number of columns in the matrix (generated by a call to loadMat() or by starting an optimization run from BCL). If the solution is loaded into BCL the values are accepted as is, if the solution is loaded into the Optimizer (ifopt = true), the Optimizer will check whether the solution is acceptable and recalculates the values for the continuous variables in the solution. In the latter case the solution is loaded into BCL only once it has been successfully loaded and validated by the Optimizer.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 double[] vals = {1.5, 1, 0, 4, 2.2};     // Assuming we have 5 variables
                 if(expl2.loadMIPSol(vals)!=0)
                     System.out.println("Loading MIP solution failed");
             }
         
        Parameters:
        sol - Array holding the solution values.
        ifopt - Whether to load the solution into the Optimizer:
        • false load into BCL only
        • true load solution into the Optimizer.
        Returns:
        Solution status. Possible values:
        • 0 problem has not been loaded
        • 1 solution accepted,
        • 2 solution rejected because it is infeasible,
        • 3 solution rejected because the LP reoptimization was interrupted,
        • -1 solution rejected because an error occurred,
        • -2 the given solution array does not have the expected size,
        • -3 error loading solution into BCL.
      • addMIPSol

        public void addMIPSol(XPRBsol sol,
                              java.lang.String name)
        Add a MIP solution into the Optimizer. This method adds a MIP solution from an external source into the Optimizer. The solution is given in the form of an XPRBsol object and can be feasible, infeasible or partial. The function returns immediately after passing the solution to the Optimizer. The solution is placed in a pool until the Optimizer is able to analyze the solution during a MIP solve. If the provided solution is found to be infeasible, a limited local search heuristic will be run in an attempt to find a close feasible integer solution. If a partial solution is provided, global columns will be fixed to any provided values and a limited local search will be run in an attempt to find integer feasible values for the remaining unspecified columns. Values provided for continuous column in partial solutions are currently ignored.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 XPRBvar x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
                 XPRBsol sol1 = expl2.newSol();
                 sol1.addVar(x1, 1.0);
                 expl2.addMIPSol(sol1, "mysol");
             }
         
        Parameters:
        sol - Solution object holding the solution values.
        name - An optional name to associate with the solution (can be null).
      • getObjVal

        public double getObjVal()
        Get the objective function value.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.lpOptimize();
                 double objval = expl2.getObjVal();
             }
         
        Returns:
        Current objective function value (default 0)
      • getNumIIS

        public int getNumIIS()
        Get the number of independent IIS. The methods returns the number of independent irreducible infasible sets found by Xpress-Optimizer for an infeasible LP problem. The contents (variables and constraints) of each IIS can be retrieved with the method getIIS(java.util.ArrayList, java.util.ArrayList).
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 int num = 0;
                 expl2.lpOptimize("");
                 if(expl2.getLPStat()==XPRB.LP_INFEAS) num = expl2.getNumIIS();
             }
         
        Returns:
        Number of independent IIS
      • getIIS

        public void getIIS(java.util.ArrayList arrvar,
                           java.util.ArrayList arrctr,
                           java.util.ArrayList arrsos,
                           int num)
        Get IIS variables, constraints, and SOS. This method returns the variables and/or constraints forming an IIS (irreducible infeasible set) in an infeasible LP or MIP problem. The number of independent IIS identified by Xpress-Optimizer can be obtained with method getNumIIS(). The class ArrayList is defined in java.util.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.lpOptimize();
                 if (expl2.getLPStat()==XPRB.LP_INFEAS) {
                      ArrayList iisvar = new ArrayList();
                      expl2.getIIS(iisvar, null, null, 1);
                      for (int i=0;i<iisvar.size();i++)
                          System.out.println(((XPRBvar)iisvar.get(i)).getName());
                 }
             }
         
        Parameters:
        arrvar - list of variables (may be null)
        arrctr - list of constraints (may be null)
        arrsos - list of SOS (may be null)
        num - sequence number of the IIS (default: 1)
      • getVarByName

        public XPRBvar getVarByName(java.lang.String name)
        Retrieve a variable by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.newVar("abc3", XPRB.UI, 1, 100);
                 XPRBvar x1 = expl2.getVarByName("abc3");
             }
         
        Parameters:
        name - name of the variable
        Returns:
        A variable of type XPRBvar (check its validity with XPRBvar.isValid())
      • getCtrByName

        public XPRBctr getCtrByName(java.lang.String name)
        Retrieve a constraint by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.newCtr("r1");
                 XPRBctr ctr1 = expl2.getCtrByName("r1");
             }
         
        Parameters:
        name - name of the constraint
        Returns:
        A constraint of type XPRBctr (check its validity with XPRBctr.isValid())
      • getCtrs

        public java.lang.Iterable<XPRBctr> getCtrs()
        Returns an iterable (anonymous) object over the constraints in this problem.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.newCtr("r1");
                 for (XPRBctr c : expl2.getCtrs()) {
                     c.print();
                 }
             }
         
        Returns:
        An iterable of type Iterable<XPRBctr>
      • getSosByName

        public XPRBsos getSosByName(java.lang.String name)
        Retrieve a SOS by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.newSos("sos1", XPRB.S1);
                 XPRBsos set = expl2.getSosByName("sos1");
             }
         
        Parameters:
        name - name of the SOS
        Returns:
        A SOS of type XPRBsos (check its validity with XPRBsos.isValid())
      • getIndexSetByName

        public XPRBindexSet getIndexSetByName(java.lang.String name)
        Retrieve an index set by its name. This method cannot be used if the names dictionary has been disabled. Note that the same name may be used for objects of different types within one problem definition.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.newIndexSet("Set",100);
                 XPRBindexSet iset = expl2.getIndexSetByName("Set");
             }
         
        Parameters:
        name - name of the index set
        Returns:
        An index set of type XPRBindexSet (check its validity with XPRBindexSet.isValid())
      • setDictionarySize

        public void setDictionarySize(int dico,
                                      int size)
        Set the size of a dictionary. This method sets the size of the names or indices dictionaries. It can only be called immediately after the creation of a problem.
        The names dictionary serves for storing and accessing the names of all modeling objects (variables, arrays of variables, constraints, SOS, index sets). Once the names dictionary has been disabled it cannot be enabled any more. All methods relative to the names cannot be used if this dictionary has been disabled and BCL will not generate any unique names at the creation of model objects. If this dictionary is enabled (default setting) BCL automatically resizes this dictionary to a suitable size for your problem. If nevertheless you wish to set the size by yourself we recommend to choose a size close to the number of variables+constraints in your problem.
        The indices dictionary serves for storing all index set elements. The indices dictionary cannot be disabled, it is created automatically once an index set element is defined.
             try (XPRBprob expl2 new XPRBprob("example2")) {
                 expl2.setDictionarySize(XPRB.DICT_NAMES, 0);
                 expl2.setDictionarySize(XPRB.DICT_IDX, 2999);
             }
         
        Parameters:
        dico - name of the index set. Possible values:
        • XPRB.DICT_NAMES names dictionary
        • XPRB.DICT_IDX index set dictionary
        size - size of the dictionary, 0 disables the dictionary (names only)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class  java.lang.Object
        See Also:
        getName()
      • print

        public void print()
        Print out a problem. This method prints out the complete problem definition currently held in BCL, that means, the list of constraints, any Special Ordered Sets that have been defined, and the objective function. This method is not available in the Student Edition.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.print();
             }
         
      • getXPRSintAttrib

        @Deprecated
        public int getXPRSintAttrib(int c)
        Deprecated.  Use getXPRSprob in conjunction with getIntAttrib
        Get an integer problem attribute from the optimizer. This method returns the current value of an integer-valued problem attribute of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all problem attributes. It may be necessary to load the BCL problem explicitly (method loadMat()) into Xpress-Optimizer before this method is used.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.loadMat();
                 int val = expl2.getXPRSintAttrib(XPRB.XPRS_MIPSOLS);
             }
         
        Parameters:
        c - name of the control parameter
        Returns:
        Current value of the problem attribute
        See Also:
        getXPRSprob(), XPRSprob.getIntAttrib(int)
      • getXPRSdblAttrib

        @Deprecated
        public double getXPRSdblAttrib(int c)
        Deprecated.  Use getXPRSprob in conjunction with getDblAttrib
        Get a double problem attribute from the optimizer. This method returns the current value of a double-valued problem attribute of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all problem attributes. It may be necessary to load the BCL problem explicitly (method loadMat()) into Xpress-Optimizer before this method is used.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 double val = expl2.getXPRSdblAttrib(XPRB.XPRS_LPOBJVAL);
             }
         
        Parameters:
        c - name of the control parameter
        Returns:
        Current value of the problem attribute
        See Also:
        getXPRSprob(), XPRSprob.getDblAttrib(int)
      • getXPRSintControl

        @Deprecated
        public int getXPRSintControl(int c)
        Deprecated.  Use getXPRSprob in conjunction with getIntControl
        Get an integer control parameter from the optimizer. This method returns the current value of an integer-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 int val = expl2.getXPRSintControl(XPRB.XPRS_PRESOLVE);
             }
         
        Parameters:
        c - name of the control parameter
        Returns:
        Current value of the control parameter
        See Also:
        getXPRSprob(), XPRSprob.getIntControl(int)
      • getXPRSdblControl

        @Deprecated
        public double getXPRSdblControl(int c)
        Deprecated.  Use getXPRSprob in conjunction with getDblControl
        Get a double control parameter from the optimizer. This method returns the current value of a double-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 double val = expl2.getXPRSdblControl(XPRB.XPRS_MIPTOL);
             }
         
        Parameters:
        c - name of the control parameter
        Returns:
        Current value of the control parameter
        See Also:
        getXPRSprob(), XPRSprob.getDblControl(int)
      • setXPRSintControl

        @Deprecated
        public void setXPRSintControl(int c,
                                                  int val)
        Deprecated.  Use getXPRSprob in conjunction with setIntControl
        Set an integer control parameter for the optimizer. This method sets a new value for an integer-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setXPRSintControl(XPRB.XPRS_MAXMIPSOL,1);
             }
         
        Parameters:
        c - name of the control parameter
        val - new value for the control parameter
        See Also:
        getXPRSprob(), XPRSprob.setIntControl(int,int)
      • setXPRSdblControl

        @Deprecated
        public void setXPRSdblControl(int c,
                                                  double val)
        Deprecated.  Use getXPRSprob in conjunction with setDblControl
        Set a double control parameter for the optimizer. This method sets a new value for a double-valued control parameter of Xpress-Optimizer. Refer to the Optimizer Reference Manual for a list of all control parameters.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setXPRSdblControl(XPRB.XPRS_MIPADDCUTOFF,0.99);
             }
         
        Parameters:
        c - name of the control parameter
        val - new value for the control parameter
        See Also:
        getXPRSprob(), XPRSprob.setDblControl(int,double)
      • getXPRSprob

        public com.dashoptimization.XPRSprob getXPRSprob()
        Retrieve the associated XPRSprob object. This method returns an XPRSprob object to be used with specific Xpress-Optimizer operations. The Xpress-Optimizer Java needs to be initialized with XPRS.init() before the Optimizer problem is accessed.
      • setCutMode

        public void setCutMode(int mode)
        Parameter settings for cuts. This methods sets certain Xpress-Optimizer control parameters to enable the addition of cuts defined in BCL during the MIP search.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 expl2.setCutMode(1);
             }
         
        Parameters:
        mode - choice of parameter settings. Possible values:
        • 0 standard settings
        • 1 parameter settings required for cuts
      • addCuts

        public void addCuts(XPRBcut[] ca)
        Add an array of cuts to the Optimizer problem. This method adds an array of previously defined cuts to the problem currently held in Xpress-Optimizer. Typically, this method will be called from the cut manager callback of the Optimizer ( XPRScutMgrListener). Cuts are not stored in the BCL problem.
             static class CutMgrCallback implements XPRScutMgrListener {
                 public int XPRScutMgrEvent(XPRSprob oprob, Object data) {
                     XPRBcur[] cut;
                     XPRBprob pb;
                     pb = (XPRBprob)data;
                     ...   // Definition of cuts in array "cut"
                     pb.addCuts(cut);
                 }
             }
             ...
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 CutMgrCallback cb = new CutMgrCallback();
                 expl2.addCutMgrListener(cb, expl2);
             }
         
        Parameters:
        ca - array of previously defined cuts (type XPRBcut)
      • writeSol

        public void writeSol(java.lang.String fname,
                             java.lang.String flags)
                      throws java.io.IOException
        Write solution to a CSV file. This method writes the current Optimizer solution to a CSV format ASCII file (.asc and .hdr). Please refer to the documentation of XPRSwritesol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.writeSol("myprob", "nar");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • writeBinSol

        public void writeBinSol(java.lang.String fname,
                                java.lang.String flags)
                         throws java.io.IOException
        Write solution to a binary file. Writes the current MIP or LP Optimizer solution to a binary solution file (.sol) for later input into the Optimizer. Please refer to the documentation of XPRSwritebinsol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.writeBinSol("myprob", "x");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • writePrtSol

        public void writePrtSol(java.lang.String fname,
                                java.lang.String flags)
                         throws java.io.IOException
        Write solution to a fixed format ASCII file. Writes the current Optimizer solution to a fixed format ASCII file(.prt). Please refer to the documentation of XPRSwriteprtsol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.writePrtSol("myprob", "x");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • writeSlxSol

        public void writeSlxSol(java.lang.String fname,
                                java.lang.String flags)
                         throws java.io.IOException
        Write solution to an ASCII file. Writes the current Optimizer solution to an ASCII solution file (.slx) using a similar format to MPS files. Please refer to the documentation of XPRSwriteslxsol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.writeSlxSol("myprob", "pm");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • readBinSol

        public void readBinSol(java.lang.String fname,
                               java.lang.String flags)
                        throws java.io.IOException
        Read solution from a binary file. Reads a binary solution file (.bin) created by the writeBinSol method, loading it into the Optimizer. Please refer to the documentation of XPRSreadbinsol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.readBinSol("myprob", "m");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • readSlxSol

        public void readSlxSol(java.lang.String fname,
                               java.lang.String flags)
                        throws java.io.IOException
        Read solution from an ASCII file. Reads an ASCII solution file (.slx) created by the writeSlxSol method, loading it into the Optimizer. Please refer to the documentation of XPRSreadslxsol in the Xpress Optimizer Reference Manual for a description of the various flags.
             try (XPRBprob expl2 = new XPRBprob("example2")) {
                 ...
                 expl2.readSlxSol("myprob", "m");
             }
         
        Parameters:
        fname - name of the output file without extension
        Throws:
        java.io.IOException
      • close

        public void close()
        Finalize the problem. If this method is called explicitly from the user's program to force the finalization of a BCL problem (as required by XPRB.close()) the program must not access any objects of the problem after this call. It is recommended to call this function only implicitly through try-with-resources.
             try (XPRB bcl=new XPRBprob("example2")) { // Create a problem
                 ...
             }                                         // Finalize the problem
         
        Specified by:
        close in interface  java.lang.AutoCloseable
        Since:
        8.14
      • setExplicitGarbageCollect

        public boolean setExplicitGarbageCollect(boolean value)
      • 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

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