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


IISExample.java
import com.dashoptimization.*;

class IISExample implements XPRSmessageListener
{
    public void Run_getIISData(XPRSprob problem, int i) 
    {
      IntHolder ncol = new IntHolder(), nrow = new IntHolder();
      problem.getIISData(i, nrow, ncol, null, null, null, null, null, null, null, null);
      int[]     miisrow         = new int[nrow.value];
      int[]     miiscol         = new int[ncol.value];
      byte[]    constrainttype  = new byte[nrow.value];
      byte[]    colbndtype      = new byte[ncol.value];
      double[]  duals           = new double[nrow.value];
      double[]  rdcs            = new double[ncol.value];
      byte[]    isolationrows   = new byte[nrow.value];
      byte[]    isolationcols   = new byte[ncol.value];
      problem.getIISData(i, nrow, ncol, miisrow, miiscol, constrainttype, colbndtype, duals, rdcs, isolationrows, isolationcols);
    }

    public void Run_IISStatus(XPRSprob problem, int i) 
    {
      IntHolder count = new IntHolder();
      problem.IISStatus(count, null, null, null, null);
      int[]     rowsizes        = new int[count.value + 1];
      int[]     colsizes        = new int[count.value + 1];
      double[]  suminfeas       = new double[count.value + 1];
      int[]     numinfeas       = new int[count.value + 1];
      problem.IISStatus(count, rowsizes, colsizes, suminfeas, numinfeas);
    }

    public void run (int iMode)
    {
      try {
        XPRSprob problem = new XPRSprob ();
        int i = 0;

        problem.setIntControl (XPRS.LPLOG, 1);
        problem.addMessageListener(this,null);

        problem.readProb ("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(i = 1; i < problem.getIntAttrib(XPRS.NUMIIS); i++) {
            Run_getIISData(problem, i);
            Run_IISStatus(problem, i);
            problem.writeIIS(i, "iis_result" + i, 0);
          }
          break;
        case(1) :
          i = 0;
          /* Get the iis one at a time */
          if(problem.firstIIS(1) == 0) {
            do {
              i++;
              Run_getIISData(problem, i);
              Run_IISStatus(problem, i);
              problem.writeIIS(i, "iis_result" + i, 0);
            } while(problem.nextIIS() == 0);
          }
          break;
        }

        problem.removeMessageListener();
      } catch(XPRSprobException xpe) {
        xpe.printStackTrace();
      }
    }

    public void XPRSmessageEvent(XPRSprob prob,
          Object data, String msg, int len, int type)
    {
      if(msg != null) 
      System.out.println (msg);
    }

    public static void main(String [] args)
    {
      try {
        XPRS.init ();
      } catch (Exception e) {
        System.out.println ("Failed to initialize");
        return;
      }

      try {
        IISExample c = new IISExample ();
        c.run (0);
        c.run (1);

      } finally { 
        XPRS.free ();
      }

    }
}


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