Initializing help system before first use

Irreducible Infeasible Set Search


Type: Programming
Rating: 4 (medium-difficult)
Description:

Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)

File(s): IISExample.java
Data file(s): iisexample.mps


IISExample.java
import com.dashoptimization.DefaultMessageListener;
import com.dashoptimization.XPRS;
import com.dashoptimization.XPRSprob;
import com.dashoptimization.XPRSprobException;

import java.util.Arrays;

import static com.dashoptimization.XPRSprob.IISData;
import static com.dashoptimization.XPRSprob.IISStatusInfo;

/** Example class to illustrate finding and iterating IISs.
 */
public class IISExample {
    /** Print information about IIS.
     * @param problem The problem instance storing the ISSs.
     * @param num     Number of the IIS to print.
     */
    public void printIIS(XPRSprob problem, int num) {
        System.out.println("IIS " + num + ":");

        // getIISData(int) returns information about a particular IIS.
        // IISData has more fields than we print here. Please refer to the
        // reference documentation for more details.
        IISData data = problem.getIISData(num);
        System.out.println("  infeasible rows: " + Arrays.toString(data.rowind));
        System.out.println("  infeasible cols: " + Arrays.toString(data.colind));

        // IISStatus() returns information about all IISs found so far.
        // IISStatusInfo has more fields than we print here, please refer to
        // the reference documentation for more details.
        IISStatusInfo info = problem.IISStatus();
        System.out.println("  infeasibilities: " + Arrays.toString(info.suminfeas));
    }

    /** Iterate over IIS in a model and print each.
     * @param iMode IIS iteration mode:
     *              0 to compute all IISs in one shot and then iterate,
     *              1 to compute IISs one by one.
     */
    public void run (int iMode) {
        try (XPRSprob problem = new XPRSprob(null)) {
            problem.setIntControl (XPRS.LPLOG, 1);
            problem.addMessageListener(DefaultMessageListener::console);

            problem.readProb ("../data/iisexample","");

            problem.setIntControl(XPRS.PRESOLVE, -1);
            problem.lpOptimize ("");

            switch(iMode) {
            case(0) :
                /* Get all iis at once and then iterate through the results */
                problem.IISAll();
                for(int i = 1; i < problem.getIntAttrib(XPRS.NUMIIS); i++) {
                    printIIS(problem, i);
                    problem.writeIIS(i, "iis_result" + i, 0);
                }
                break;
            case(1) :
                /* Get the iis one at a time */
                if (problem.firstIIS(1) == 0) {
                    int i = 0;
                    do {
                        i++;
                        printIIS(problem, i);
                        problem.writeIIS(i, "iis_result" + i, 0);
                    } while (problem.nextIIS() == 0);
                }
                break;
            }
        }
    }

    public static void main(String [] args)
    {
        IISExample c = new IISExample ();
        c.run (0);
        c.run (1);
    }
}


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