Initializing help system before first use

Collecting all solutions with the MIP solution pool


Type: Power generation
Rating: 3 (intermediate)
Description: We take the power generation problem stored in hpw15.mps which seeks to optimise the operating pattern of a group of electricity generators. We solve the problem collecting all solutions found during the MIP search. The optimal solution's objective and solution values are printed to screen.
File(s): MipSolPool.java
Data file(s): hpw15.mps


MipSolPool.java
/***************************************************************************************\
* Name:        MipSolPool.java                                   Fair Isaac 13/06/2008 *
* Purpose:     All solutions with the MIP solution pool                                *
* Description: We take the power generation problem stored in hpw15.mps which seeks to *
*              optimise the operating pattern of a group of electricity generators. We *
*              solve the problem collecting all solutions found during the MIP search. *
*              The optimal solution's objective and solution values are printed to     *
*              screen.                                                                 *
* Input:       hpw15.mps                                                               *
\***************************************************************************************/

import java.io.*;
import com.dashoptimization.*;

public class MipSolPool {
	public static void main(String[] args) throws Exception {
        String model = args.length == 0 ? "../data/hpw15" : args[0];
        try (XPRSprob prob = new XPRSprob(null)) {
			prob.addMsgHandlerListener(System.out);

			XPRSmipsolpool msp = new XPRSmipsolpool();

			msp.probAttach(prob);

			prob.readProb(model);

			prob.mipOptimize("g");

			int nSols = msp.attributes().getSolutions();

			if (nSols>0) {
				IntHolder iSolutionId = new IntHolder();
				DoubleHolder dObj = new DoubleHolder();
				msp.getDblAttribProbExtreme(prob,0,iSolutionId, XPRS.MSP_SOLPRB_OBJ, dObj);

				System.out.println("Optimal Solution ID: " + iSolutionId.value);
				System.out.println("Optimal Objective  : " + dObj.value);


				int nCols = msp.getIntAttribSol(iSolutionId.value, null, XPRS.MSP_SOL_COLS);
				for (int i=0;i<nCols;i++) {
					double[] dSol = new double[1];
					msp.getSol(iSolutionId.value,null,dSol,i,i,null);
					System.out.println(i + " = " + dSol[0]);
				}
			}

		}
	}
}

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