Initializing help system before first use

10 best solutions with the MIP solution enumerator


Type: Power generation
Rating: 3 (intermediate)
Description: We take the power generation problem stored in hpw15.mat which seeks to optimise the operating pattern of a group of electricity generators. We run the MIP solution enumerator on the problem using the default setup obtaining the best 10 solutions. The best 10 solutions are stored to a MIP solution pool. The solutions' objectives and solution values are printed to screen.
File(s): MipSolEnum.vb
Data file(s): hpw15.mat


MipSolEnum.vb
Imports System
Imports Microsoft.VisualBasic
Imports Optimizer
Imports System.IO

'/***************************************************************************************\
'* Name:        MipSolEnum.vb                                      FairIsaac 13/06/2008 *
'* Purpose:     10 best solutions with the MIP solution enumerator                      *
'* Description: We take the power generation problem stored in hpw15.mat which seeks to *
'*              optimise the operating pattern of a group of electricity generators. We *
'*              run the MIP solution enumerator on the problem using the default setup  *
'*              obtaining the best 10 solutions. The best 10 solutions are stored to a  *
'*              MIP solution pool.  The solutions' objectives and solution values are   *
'*              printed to screen.                                                      *
'* Input:       hpw15.mat                                                               *
'\***************************************************************************************/

Module MipSolEnum
    Public Sub RunMipSolEnum(ByRef Log As TextWriter)
        XPRS.Init("")
        Log.WriteLine(XPRS.GetBanner)

        Dim prob As New XPRSprob
        ' Tell Optimizer to send all messages to Log '
        prob.AddMsgHandlerCallback(Log)
        ' Get and display the Optimizer version number
        Log.WriteLine( _
            vbCrLf & "Xpress Optimizer Subroutine Library Release {0}" & vbCrLf & vbCrLf, _
            prob.Version / 100 _
        )

        Dim msp As New XPRSmipsolpool
        Dim mse As New XPRSmipsolenum

        prob.ReadProb("../Data/hpw15")
        Dim nCols As Integer = prob.Cols

        ' Disable heuristics to avoid duplicate solutions being stored
        prob.HeurStrategy = 0

        Dim iPresolveOps as Long
        iPresolveOps = prob.PresolveOps
        iPresolveOps = iPresolveOps And Not (1 << 3) ' Disable dual reduction operations
        iPresolveOps = iPresolveOps And Not (1 << 5) ' Disable duplicate column removal
        prob.PresolveOps = iPresolveOps

        Dim iMIPPresolve as Long
        iMIPPresolve = prob.MIPPresolve
        iMIPPresolve = iMIPPresolve And Not (1 << 4) ' Disable MIP dual reduction operations
        prob.MIPPresolve = iMIPPresolve

        ' Run the enumeration '
        Dim nMaxSols As Integer = 10
        mse.Minim(prob, msp, XPRSdefaultMipSolEnumHandler.GetDefaultHandlerCallback(), Nothing, nMaxSols)

        ' Print out the solutions found
        Dim nSols As Integer = mse.Solutions
        Log.WriteLine("Enumerated best {0} solutions", nSols)
        Dim i As Integer
        For i = 1 To nSols
            Dim iSolutionId(1) As Integer
            Dim dObj As Double
            Dim nSols2, nReturnedSolIds, solutionIdStatus As Integer
            mse.GetSolList(XPRSattribute.Mse_Metric_MipObject, i, i, iSolutionId, nReturnedSolIds, nSols2)
            mse.GetSolMetric(iSolutionId(0), solutionIdStatus, XPRSattribute.Mse_Metric_MipObject, dObj)
            Log.WriteLine("--------")
            Log.WriteLine("{0} = {1}", i, dObj)
            Dim j As Integer
            For j = 0 To nCols - 1
                Dim dSol(1) As Double
                Dim nValuesReturned As Integer
                msp.GetSol(iSolutionId(0), solutionIdStatus, dSol, j, j, nValuesReturned)
                Log.WriteLine("{0} = {1}", j, dSol(0))
            Next

        Next

    End Sub

End Module

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