1#if defined(_WIN32) && !defined(_WIN64)
2#define dec_directives_win32
11 Character(len=128):: Progname
12 Integer :: Stacalls = 0
44 read(*,
"(A)") progname
45 call flog(
"Starting to execute", 0 )
49 open(10,file=trim(progname) //
'.lst',status=
'Unknown')
50 open(11,file=trim(progname) //
'.sta',status=
'Unknown')
59 Subroutine flog( Msg, Code )
61 character(len=*),
Intent(IN) :: Msg
62 Integer,
Intent(IN) :: Code
64 open(15,file=trim(progname) //
'.rc',action=
'write',form=
'formatted',status=
'unknown')
65 write(15,
"(A,': ',A)") trim(progname), msg
82 if (
associated(
xdual) )
Then
86 if (
associated(
uprim) )
Then
90 if (
associated(
udual) )
Then
94 if (
associated(
xbasc) )
Then
98 if (
associated(
xstat) )
Then
102 if (
associated(
ubasc) )
Then
106 if (
associated(
ustat) )
Then
123Integer Function std_status( MODSTA, SOLSTA, ITER, OBJVAL, USRMEM )
124#ifdef dec_directives_win32
132 INTEGER,
Intent(IN) :: modsta, solsta, iter
133 real*8,
Intent(IN) :: objval
134 real*8,
Intent(IN OUT) :: usrmem(*)
137 WRITE(*,*)
'CONOPT has finished optimizing.'
138 WRITE(*,*)
'Model status =',modsta
139 WRITE(*,*)
'Solver status =',solsta
140 WRITE(*,*)
'Iteration count=',iter
141 WRITE(*,*)
'Objective value=',objval
144 WRITE(10,*)
'CONOPT has finished optimizing.'
145 WRITE(10,*)
'Model status =',modsta
146 WRITE(10,*)
'Solver status =',solsta
147 WRITE(10,*)
'Iteration count=',iter
148 WRITE(10,*)
'Objective value=',objval
151 WRITE(11,*)
'Model status =',modsta
152 WRITE(11,*)
'Solver status =',solsta
153 WRITE(11,*)
'Objective value=',objval
167Integer Function std_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
168#ifdef dec_directives_win32
179 INTEGER,
Intent(IN) :: n, m
180 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
181 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
182 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
183 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
184 real*8,
Intent(IN OUT) :: usrmem(*)
187 CHARACTER*5,
Parameter,
Dimension(4) :: basc = (/
'Lower',
'Upper',
'Basic',
'Super' /)
188 CHARACTER*6,
Parameter,
Dimension(4) :: stat = (/
'Normal',
'NonOpt',
'Infeas',
'Unbnd ' /)
193 WRITE(10,
"(/' Variable Solution value Reduced cost Var-Basc Var-stat')")
195 WRITE(10,
"(1P,I7,E20.6,E16.6,4X,A5,7X,A6 )") i, xval(i), xmar(i), basc(1+xbas(i)), stat(1+xsta(i))
201 WRITE(10,
"(/' Constrnt Activity level Marginal cost Con-Basc Con-stat')")
203 WRITE(10,
"(1P,I7,E20.6,E16.6,4X,A5,7X,A6 )") i, yval(i), ymar(i), basc(1+ybas(i)), stat(1+ysta(i))
208 if (
c_nonopt > 0 )
write(10,
"(/' Number of non-optimalities =',i5)")
c_nonopt
209 if (
c_infeas > 0 )
write(10,
"(/' Number of infeasibilities =',i5)")
c_infeas
214 If (
maxvar > 0 ) then; na =
maxvar; else; na = n;
Endif
215 If (
maxcon > 0 ) then; ma =
maxcon; else; ma = m;
Endif
219 If (
associated(
xprim) .and.
associated(
xdual) .and.
associated(
uprim) .and.
associated(
udual) )
Then
220 If (
Size(
xprim) >= n .and.
Size(
xdual) >= n .AND.
Size(
uprim) >= m .and.
Size(
udual) >= m )
Then
221 xprim(1:n) = xval(1:n)
222 xdual(1:n) = xmar(1:n)
223 uprim(1:m) = yval(1:m)
224 udual(1:m) = ymar(1:m)
227 If (
associated(
xbasc) .and.
associated(
xstat) .and.
associated(
ubasc) .and.
associated(
ustat) )
Then
228 If (
Size(
xbasc) >= n .and.
Size(
xstat) >= n .AND.
Size(
ubasc) >= m .and.
Size(
ustat) >= m )
Then
229 xbasc(1:n) = xbas(1:n)
230 xstat(1:n) = xsta(1:n)
231 ubasc(1:m) = ybas(1:m)
232 ustat(1:m) = ysta(1:m)
240Integer Function std_message( SMSG, DMSG, NMSG, LLEN, USRMEM, MSGV )
241#ifdef dec_directives_win32
252 INTEGER,
Intent(IN) :: smsg, dmsg, nmsg
253 INTEGER,
Intent(IN) ,
Dimension(*) :: llen
254 CHARACTER(Len=133),
Intent(IN),
Dimension(*) :: msgv
255 real*8,
Intent(IN OUT) :: usrmem(*)
262 write(*,
"(A)") msgv(i)(1:llen(i))
268 write(11,
"(A)") msgv(i)(1:llen(i))
274 write(10,
"(A)") msgv(i)(1:llen(i))
283Integer Function std_errmsg( ROWNO, COLNO, POSNO, MSGLEN, USRMEM, MSG )
284#ifdef dec_directives_win32
296 INTEGER,
Intent(IN) :: rowno, colno, posno, msglen
297 CHARACTER(len=*),
Intent(IN) :: msg
298 real*8,
Intent(IN OUT) :: usrmem(*)
304 IF ( rowno .EQ. 0 )
THEN
305 WRITE(10,1001) colno, msg(1:msglen)
306 WRITE(11,1001) colno, msg(1:msglen)
307 ELSEIF ( colno .EQ. 0 )
THEN
308 WRITE(10,1002) rowno, msg(1:msglen)
309 WRITE(11,1002) rowno, msg(1:msglen)
311 WRITE(10,1000) colno, rowno, msg(1:msglen)
312 WRITE(11,1000) colno, rowno, msg(1:msglen)
3161002
FORMAT(
'Equation',i8,
' : ',a)
3171001
FORMAT(
'Variable',i8,
' : ',a)
3181000
FORMAT(
'Variable',i8,
' appearing in Equation',i8,
' : ',a)
324Integer Function std_triord( Mode, Type, Status, Irow, Icol, Inf, Value, Resid, Usrmem )
325#ifdef dec_directives_win32
332 INTEGER,
INTENT(IN) :: mode,
Type, status, irow, icol, inf
333 real*8,
INTENT(IN) ::
VALUE, resid
334 real*8,
Intent(IN OUT) :: usrmem(*)
338 Integer,
Parameter :: pretriangular = 1, &
359 pretriainfeasb = 13, &
361 pretriainfeasl = 14, &
363 forcinginfeas = 15, &
364 inconsistentrow = 16, &
365 wforcinginfeas = 17, &
371 If ( mode == -1 )
THEN
372 write(10,
"(/'The preprocessing transformation are described below in detection order:'/)")
373 Else if ( mode == -2 )
Then
374 write(10,
"(//'The order of the critical transformations is:'/)")
379 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',1p,e18.10)") irow, icol,
value
380 Elseif ( inf == 1 )
Then
381 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',9x,'+Infinity')") irow, icol
383 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',9x,'-Infinity')") irow, icol
386 WRITE(10,
"('Variable',i7,' fixed at value=',1p,e18.10)") icol,
value
388 WRITE(10,
"('Equation',i7,' is dependent (all variables are fixed.)')") irow
390 WRITE(10,
"('Equation',i7,' is redundant (will later be solved with respect to the slack.)')") irow
392 WRITE(10,
"('Equation',i7,' turned into lower bound on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
394 WRITE(10,
"('Equation',i7,' turned into upper bound on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
396 WRITE(10,
"('Ranged Equation',i7,' turned into two bounds on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
398 WRITE(10,
"('Variable',i7,' forced to lower bound=',1p,e18.10)") icol,
value
400 WRITE(10,
"('Variable',i7,' forced to upper bound=',1p,e18.10)") icol,
value
402 WRITE(10,
"('Variable',i7,' forced to implied bound=',1p,e18.10)") icol,
value
404 WRITE(10,
"('Previous variables were forced by equation',i7,' binding as a less than or equal constraint.')") irow
406 WRITE(10,
"('Previous variables were forced by equation',i7,' binding as a greater than or equal constraint.')") irow
407 Case (pretriainfeasb)
408 WRITE(10,
"('Equation',i7,' cannot be solved with respect to variable',i7,' due to bounds. Value=',1p,e18.10)") &
410 Case (pretriainfeasl)
412 "('Equation',i7,' cannot be solved with respect to variable',i7,'. Infeasibility has local minimum at',1p,e18.10)") &
415 WRITE(10,
"('Equation',i7,' is still infeasible after the above variables have been forced to their best bounds.')") irow
416 Case (inconsistentrow)
417 WRITE(10,
"('Equation',i7,' cannot be solved. No free variables left.')") irow
419 WRITE(10,
"('Pretriangular action=',i7,' not implemented yet.')")
type
422 If ( resid /= 0.d0 )
write(10,
"('Residual after last transformation=',1p,e18.10)") resid
444 Character(Len=*),
Intent(IN) :: Case
445 INTEGER,
INTENT(IN) :: MinMax
447 real*8,
Parameter :: opttol = 2.d-6
449 Character(Len=120) Text
452 If ( .not. (
associated(
xprim) .and.
associated(
xdual) .and.
associated(
uprim) .and.
associated(
udual) ) )
Return
453 If ( .not. (
associated(
xbasc) .and.
associated(
xstat) .and.
associated(
ubasc) .and.
associated(
ustat) ) )
Return
457 do i = 1,
Size(
xstat)
458 If (
xstat(i) /= 0 )
then
459 write(text,
"(A,': Status of variable',i6,' is not zero(normal). Is',i10)")
Case, i,
xstat(i)
460 call flog( trim(text), 1 )
466 do i = 1,
size(
xbasc)
467 select case(
xbasc(i))
470 if (
xdual(i) > opttol )
then
471 write(text,
"(A,': Max and variable',i6,' at lower. Reduced cost is positive:',1p,d15.6)")
Case, i,
xdual(i)
472 call flog( trim(text), 1 )
475 if (
xdual(i) < -opttol )
then
476 write(text,
"(A,': Min and variable',i6,' at lower. Reduced cost is negative:',1p,d15.6)")
Case, i,
xdual(i)
477 call flog( trim(text), 1 )
482 if (
xdual(i) < -opttol )
then
483 write(text,
"(A,': Max and variable',i6,' at upper. Reduced cost is negative:',1p,d15.6)")
Case, i,
xdual(i)
484 call flog( trim(text), 1 )
487 if (
xdual(i) > opttol )
then
488 write(text,
"(A,': Min and variable',i6,' at upper. Reduced cost is positive:',1p,d15.6)")
Case, i,
xdual(i)
489 call flog( trim(text), 1 )
493 if (
xdual(i) /= 0.d0 )
then
494 write(text,
"(A,': Basic variable',i6,' does not have reduced cost zero. Is',1p,d15.6)")
Case, i,
xdual(i)
495 call flog( trim(text), 1 )
498 if ( abs(
xdual(i) ) > opttol )
then
499 write(text,
"(A,': Superbasic variable',i6,' does not have small reduced cost. Is',1p,d15.6)")
Case, i,
xdual(i)
500 call flog( trim(text), 1 )
503 write(text,
"(A,': Variable',i6,' bas illegal basis status:',I10)")
Case, i,
xbasc(i)
504 call flog( trim(text), 1 )
511 do i = 1,
Size(
ustat)
512 If (
ustat(i) /= 0 )
then
513 write(text,
"(A,': Status of constraint',i6,' is not zero(normal). Is',i10)")
Case, i,
ustat(i)
514 call flog( trim(text), 1 )
521 do i = 1,
size(
ubasc)
522 select case(
ubasc(i))
525 if (
udual(i) > opttol )
then
526 write(text,
"(A,': Max and constraint',i6,' at lower. Reduced cost is positive:',1p,d15.6)")
Case, i,
udual(i)
527 call flog( trim(text), 1 )
530 if (
udual(i) < -opttol )
then
531 write(text,
"(A,': Min and constraint',i6,' at lower. Reduced cost is negative:',1p,d15.6)")
Case, i,
udual(i)
532 call flog( trim(text), 1 )
537 if (
udual(i) < -opttol )
then
538 write(text,
"(A,': Max and constraint',i6,' at upper. Reduced cost is negative:',1p,d15.6)")
Case, i,
udual(i)
539 call flog( trim(text), 1 )
542 if (
udual(i) > opttol )
then
543 write(text,
"(A,': Min and constraint',i6,' at upper. Reduced cost is positive:',1p,d15.6)")
Case, i,
udual(i)
544 call flog( trim(text), 1 )
549 write(text,
"(A,': Basic constraint',i6,' does not have reduced cost zero. Is',1p,d15.6)")
Case, i,
udual(i)
550 call flog( trim(text), 1 )
554 write(text,
"(A,': Superbasic constraint',i6,' does not have small reduced cost. Is',1p,d15.6)")
Case, i,
udual(i)
555 call flog( trim(text), 1 )
558 write(text,
"(A,': Constraint',i6,' bas illegal basis status:',I10)")
Case, i,
ubasc(i)
559 call flog( trim(text), 1 )
integer function std_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
integer function std_status(modsta, solsta, iter, objval, usrmem)
subroutine checkdual(case, minmax)
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
integer function std_triord(mode, type, status, irow, icol, inf, value, resid, usrmem)
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
integer, dimension(:), pointer ubasc
integer, parameter bssuper
real *8, dimension(:), pointer udual
integer, parameter bslower
real *8, dimension(:), pointer xdual
integer, dimension(:), pointer xstat
integer, dimension(:), pointer xbasc
integer, dimension(:), pointer ustat
integer, parameter infeasible
integer, parameter bsbasic
integer, parameter minimize
integer, parameter bsupper
subroutine flog(msg, code)
integer, parameter maximize
real *8, dimension(:), pointer xprim
real *8, dimension(:), pointer uprim