! E04MKF Example Program Text
! Mark 30.2 Release. NAG Copyright 2024.
Program e04mkfe
! .. Use Statements ..
Use iso_c_binding, Only: c_null_ptr, c_ptr
Use nag_library, Only: e04mkf, e04mku, e04raf, e04rff, e04rhf, e04rjf, &
e04rwf, e04rzf, e04zmf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Type (c_ptr) :: cpuser, handle
Integer :: idlc, ifail, ioflag, liarr, m, n, &
nnza, nnzc, nnzu
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:), bla(:), bua(:), c(:), u(:), &
x(:), xl(:), xu(:)
Real (Kind=nag_wp) :: h(1), rinfo(100), ruser(1), &
stats(100)
Integer, Allocatable :: cindex(:), hs(:), icola(:), irowa(:)
Integer :: icolh(1), irowh(1), iuser(2)
! .. Executable Statements ..
Write (nout,*) 'E04MKF Example Program Results'
! Skip Header in data file
Read (nin,*)
! read dimensions of the problem
Read (nin,*) m, n, nnza, nnzc
nnzu = 2*n + 2*m
! Allocate memory
Allocate (cindex(nnzc),icola(nnza),irowa(nnza),a(nnza),bla(m),bua(m), &
xl(n),xu(n),c(nnzc),x(n),u(nnzu),hs(m+n))
! 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,*) x(1:n)
! 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)
! 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 LP simplex solver
cpuser = c_null_ptr
ifail = -1
Call e04mkf(handle,n,x,nnzu,u,rinfo,stats,e04mku,iuser,ruser,cpuser, &
ifail)
! Extract Basis
ioflag = 1
liarr = m + n
Call e04rwf(handle,'Basis',ioflag,liarr,hs,ifail)
! Free the handle memory
Call e04rzf(handle,ifail)
End Program e04mkfe