! H02BKF Example Program Text
! Mark 30.1 Release. NAG Copyright 2024.
Program h02bkfe
! .. Use Statements ..
Use iso_c_binding, Only: c_null_ptr, c_ptr
Use nag_library, Only: e04raf, e04rcf, e04rff, e04rhf, e04rjf, e04rzf, &
e04zmf, h02bkf, h02bku, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Type (c_ptr) :: cpuser, handle
Integer :: idlc, ifail, m, n, nnza, nnzc, &
nvar_int
Character (8) :: int_type
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:), bla(:), bua(:), c(:), x(:), &
xl(:), xu(:)
Real (Kind=nag_wp) :: h(1), rinfo(100), ruser(1), &
stats(100)
Integer, Allocatable :: cindex(:), icola(:), irowa(:), &
vidx_int(:)
Integer :: icolh(1), irowh(1), iuser(2)
! .. Executable Statements ..
Write (nout,*) 'H02BKF Example Program Results'
! Skip Header in data file
Read (nin,*)
! Read dimensions of the problem
Read (nin,*) m, n, nnza, nnzc, nvar_int
! Allocate memory
Allocate (cindex(nnzc),icola(nnza),irowa(nnza),a(nnza),bla(m),bua(m), &
xl(n),xu(n),c(nnzc),x(n),vidx_int(nvar_int))
! Read problem data
Read (nin,*) cindex(1:nnzc)
Read (nin,*) c(1:nnzc)
Read (nin,*) irowa(1:nnza)
Read (nin,*) icola(1:nnza)
Read (nin,*) a(1:nnza)
Read (nin,*) bla(1:m)
Read (nin,*) bua(1:m)
Read (nin,*) xl(1:n)
Read (nin,*) xu(1:n)
Read (nin,*) int_type
Read (nin,*) vidx_int(1:nvar_int)
! Create the problem handle
! Initialize handle
ifail = 0
Call e04raf(handle,n,ifail)
! Set objective function
Call e04rff(handle,nnzc,cindex,c,0,irowh,icolh,h,ifail)
! Set box constraints
Call e04rhf(handle,n,xl,xu,ifail)
! Set linear constraints
idlc = 0
Call e04rjf(handle,m,bla,bua,nnza,irowa,icola,a,idlc,ifail)
! Set integer variables
Call e04rcf(handle,int_type,nvar_int,vidx_int,ifail)
! Set objective sense to maximize
Call e04zmf(handle,'Task = Maximize',ifail)
! Turn off option printing
Call e04zmf(handle,'Print Options = No',ifail)
! Turn off printing of intermediate progress output
Call e04zmf(handle,'Print Level = 1',ifail)
! Require printing of the solution at the end of the solve
Call e04zmf(handle,'Print Solution = YES',ifail)
! Call MILP solver
cpuser = c_null_ptr
ifail = -1
Call h02bkf(handle,n,x,rinfo,stats,h02bku,iuser,ruser,cpuser,ifail)
! Free the handle memory
Call e04rzf(handle,ifail)
End Program h02bkfe