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
85Integer Function std_status( MODSTA, SOLSTA, ITER, OBJVAL, USRMEM )
86#ifdef dec_directives_win32
94 INTEGER,
Intent(IN) :: modsta, solsta, iter
95 real*8,
Intent(IN) :: objval
96 real*8,
Intent(IN OUT) :: usrmem(*)
99 WRITE(*,*)
'CONOPT has finished optimizing.'
100 WRITE(*,*)
'Model status =',modsta
101 WRITE(*,*)
'Solver status =',solsta
102 WRITE(*,*)
'Iteration count=',iter
103 WRITE(*,*)
'Objective value=',objval
106 WRITE(10,*)
'CONOPT has finished optimizing.'
107 WRITE(10,*)
'Model status =',modsta
108 WRITE(10,*)
'Solver status =',solsta
109 WRITE(10,*)
'Iteration count=',iter
110 WRITE(10,*)
'Objective value=',objval
113 WRITE(11,*)
'Model status =',modsta
114 WRITE(11,*)
'Solver status =',solsta
115 WRITE(11,*)
'Objective value=',objval
129Integer Function std_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
130#ifdef dec_directives_win32
141 INTEGER,
Intent(IN) :: n, m
142 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
143 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
144 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
145 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
146 real*8,
Intent(IN OUT) :: usrmem(*)
149 CHARACTER*5,
Parameter,
Dimension(4) :: basc = (/
'Lower',
'Upper',
'Basic',
'Super' /)
150 CHARACTER*6,
Parameter,
Dimension(4) :: stat = (/
'Normal',
'NonOpt',
'Infeas',
'Unbnd ' /)
155 WRITE(10,
"(/' Variable Solution value Reduced cost Var-Basc Var-stat')")
157 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))
163 WRITE(10,
"(/' Constrnt Activity level Marginal cost Con-Basc Con-stat')")
165 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))
170 if (
c_nonopt > 0 )
write(10,
"(/' Number of non-optimalities =',i5)")
c_nonopt
171 if (
c_infeas > 0 )
write(10,
"(/' Number of infeasibilities =',i5)")
c_infeas
176 If (
maxvar > 0 ) then; na =
maxvar; else; na = n;
Endif
177 If (
maxcon > 0 ) then; ma =
maxcon; else; ma = m;
Endif
181 If (
associated(
xprim) .and.
associated(
xdual) .and.
associated(
uprim) .and.
associated(
udual) )
Then
182 If (
Size(
xprim) >= n .and.
Size(
xdual) >= n .AND.
Size(
uprim) >= m .and.
Size(
udual) >= m )
Then
183 xprim(1:n) = xval(1:n)
184 xdual(1:n) = xmar(1:n)
185 uprim(1:m) = yval(1:m)
186 udual(1:m) = ymar(1:m)
189 If (
associated(
xbasc) .and.
associated(
xstat) .and.
associated(
ubasc) .and.
associated(
ustat) )
Then
190 If (
Size(
xbasc) >= n .and.
Size(
xstat) >= n .AND.
Size(
ubasc) >= m .and.
Size(
ustat) >= m )
Then
191 xbasc(1:n) = xbas(1:n)
192 xstat(1:n) = xsta(1:n)
193 ubasc(1:m) = ybas(1:m)
194 ustat(1:m) = ysta(1:m)
202Integer Function std_message( SMSG, DMSG, NMSG, LLEN, USRMEM, MSGV )
203#ifdef dec_directives_win32
214 INTEGER,
Intent(IN) :: smsg, dmsg, nmsg
215 INTEGER,
Intent(IN) ,
Dimension(*) :: llen
216 CHARACTER(Len=133),
Intent(IN),
Dimension(*) :: msgv
217 real*8,
Intent(IN OUT) :: usrmem(*)
224 write(*,
"(A)") msgv(i)(1:llen(i))
230 write(11,
"(A)") msgv(i)(1:llen(i))
236 write(10,
"(A)") msgv(i)(1:llen(i))
245Integer Function std_errmsg( ROWNO, COLNO, POSNO, MSGLEN, USRMEM, MSG )
246#ifdef dec_directives_win32
258 INTEGER,
Intent(IN) :: rowno, colno, posno, msglen
259 CHARACTER(len=*),
Intent(IN) :: msg
260 real*8,
Intent(IN OUT) :: usrmem(*)
266 IF ( rowno .EQ. 0 )
THEN
267 WRITE(10,1001) colno, msg(1:msglen)
268 WRITE(11,1001) colno, msg(1:msglen)
269 ELSEIF ( colno .EQ. 0 )
THEN
270 WRITE(10,1002) rowno, msg(1:msglen)
271 WRITE(11,1002) rowno, msg(1:msglen)
273 WRITE(10,1000) colno, rowno, msg(1:msglen)
274 WRITE(11,1000) colno, rowno, msg(1:msglen)
2781002
FORMAT(
'Equation',i8,
' : ',a)
2791001
FORMAT(
'Variable',i8,
' : ',a)
2801000
FORMAT(
'Variable',i8,
' appearing in Equation',i8,
' : ',a)
286Integer Function std_triord( Mode, Type, Status, Irow, Icol, Inf, Value, Resid, Usrmem )
287#ifdef dec_directives_win32
294 INTEGER,
INTENT(IN) :: mode,
Type, status, irow, icol, inf
295 real*8,
INTENT(IN) ::
VALUE, resid
296 real*8,
Intent(IN OUT) :: usrmem(*)
300 Integer,
Parameter :: pretriangular = 1, &
321 pretriainfeasb = 13, &
323 pretriainfeasl = 14, &
325 forcinginfeas = 15, &
326 inconsistentrow = 16, &
327 wforcinginfeas = 17, &
333 If ( mode == -1 )
THEN
334 write(10,
"(/'The preprocessing transformation are described below in detection order:'/)")
335 Else if ( mode == -2 )
Then
336 write(10,
"(//'The order of the critical transformations is:'/)")
341 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',1p,e18.10)") irow, icol,
value
342 Elseif ( inf == 1 )
Then
343 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',9x,'+Infinity')") irow, icol
345 WRITE(10,
"('Equation',i7,' solved with respect to variable',i7,'. Value=',9x,'-Infinity')") irow, icol
348 WRITE(10,
"('Variable',i7,' fixed at value=',1p,e18.10)") icol,
value
350 WRITE(10,
"('Equation',i7,' is dependent (all variables are fixed.)')") irow
352 WRITE(10,
"('Equation',i7,' is redundant (will later be solved with respect to the slack.)')") irow
354 WRITE(10,
"('Equation',i7,' turned into lower bound on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
356 WRITE(10,
"('Equation',i7,' turned into upper bound on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
358 WRITE(10,
"('Ranged Equation',i7,' turned into two bounds on variable',i7,'. Bound=',1p,e18.10)") irow, icol,
value
360 WRITE(10,
"('Variable',i7,' forced to lower bound=',1p,e18.10)") icol,
value
362 WRITE(10,
"('Variable',i7,' forced to upper bound=',1p,e18.10)") icol,
value
364 WRITE(10,
"('Variable',i7,' forced to implied bound=',1p,e18.10)") icol,
value
366 WRITE(10,
"('Previous variables were forced by equation',i7,' binding as a less than or equal constraint.')") irow
368 WRITE(10,
"('Previous variables were forced by equation',i7,' binding as a greater than or equal constraint.')") irow
369 Case (pretriainfeasb)
370 WRITE(10,
"('Equation',i7,' cannot be solved with respect to variable',i7,' due to bounds. Value=',1p,e18.10)") &
372 Case (pretriainfeasl)
374 "('Equation',i7,' cannot be solved with respect to variable',i7,'. Infeasibility has local minimum at',1p,e18.10)") &
377 WRITE(10,
"('Equation',i7,' is still infeasible after the above variables have been forced to their best bounds.')") irow
378 Case (inconsistentrow)
379 WRITE(10,
"('Equation',i7,' cannot be solved. No free variables left.')") irow
381 WRITE(10,
"('Pretriangular action=',i7,' not implemented yet.')")
type
384 If ( resid /= 0.d0 )
write(10,
"('Residual after last transformation=',1p,e18.10)") resid
406 Character(Len=*),
Intent(IN) :: Case
407 INTEGER,
INTENT(IN) :: MinMax
409 real*8,
Parameter :: opttol = 2.d-6
411 Character(Len=120) Text
414 If ( .not. (
associated(
xprim) .and.
associated(
xdual) .and.
associated(
uprim) .and.
associated(
udual) ) )
Return
415 If ( .not. (
associated(
xbasc) .and.
associated(
xstat) .and.
associated(
ubasc) .and.
associated(
ustat) ) )
Return
419 do i = 1,
Size(
xstat)
420 If (
xstat(i) /= 0 )
then
421 write(text,
"(A,': Status of variable',i6,' is not zero(normal). Is',i10)")
Case, i,
xstat(i)
422 call flog( trim(text), 1 )
428 do i = 1,
size(
xbasc)
429 select case(
xbasc(i))
432 if (
xdual(i) > opttol )
then
433 write(text,
"(A,': Max and variable',i6,' at lower. Reduced cost is positive:',1p,d15.6)")
Case, i,
xdual(i)
434 call flog( trim(text), 1 )
437 if (
xdual(i) < -opttol )
then
438 write(text,
"(A,': Min and variable',i6,' at lower. Reduced cost is negative:',1p,d15.6)")
Case, i,
xdual(i)
439 call flog( trim(text), 1 )
444 if (
xdual(i) < -opttol )
then
445 write(text,
"(A,': Max and variable',i6,' at upper. Reduced cost is negative:',1p,d15.6)")
Case, i,
xdual(i)
446 call flog( trim(text), 1 )
449 if (
xdual(i) > opttol )
then
450 write(text,
"(A,': Min and variable',i6,' at upper. Reduced cost is positive:',1p,d15.6)")
Case, i,
xdual(i)
451 call flog( trim(text), 1 )
455 if (
xdual(i) /= 0.d0 )
then
456 write(text,
"(A,': Basic variable',i6,' does not have reduced cost zero. Is',1p,d15.6)")
Case, i,
xdual(i)
457 call flog( trim(text), 1 )
460 if ( abs(
xdual(i) ) > opttol )
then
461 write(text,
"(A,': Superbasic variable',i6,' does not have small reduced cost. Is',1p,d15.6)")
Case, i,
xdual(i)
462 call flog( trim(text), 1 )
465 write(text,
"(A,': Variable',i6,' bas illegal basis status:',I10)")
Case, i,
xbasc(i)
466 call flog( trim(text), 1 )
473 do i = 1,
Size(
ustat)
474 If (
ustat(i) /= 0 )
then
475 write(text,
"(A,': Status of constraint',i6,' is not zero(normal). Is',i10)")
Case, i,
ustat(i)
476 call flog( trim(text), 1 )
483 do i = 1,
size(
ubasc)
484 select case(
ubasc(i))
487 if (
udual(i) > opttol )
then
488 write(text,
"(A,': Max and constraint',i6,' at lower. Reduced cost is positive:',1p,d15.6)")
Case, i,
udual(i)
489 call flog( trim(text), 1 )
492 if (
udual(i) < -opttol )
then
493 write(text,
"(A,': Min and constraint',i6,' at lower. Reduced cost is negative:',1p,d15.6)")
Case, i,
udual(i)
494 call flog( trim(text), 1 )
499 if (
udual(i) < -opttol )
then
500 write(text,
"(A,': Max and constraint',i6,' at upper. Reduced cost is negative:',1p,d15.6)")
Case, i,
udual(i)
501 call flog( trim(text), 1 )
504 if (
udual(i) > opttol )
then
505 write(text,
"(A,': Min and constraint',i6,' at upper. Reduced cost is positive:',1p,d15.6)")
Case, i,
udual(i)
506 call flog( trim(text), 1 )
511 write(text,
"(A,': Basic constraint',i6,' does not have reduced cost zero. Is',1p,d15.6)")
Case, i,
udual(i)
512 call flog( trim(text), 1 )
516 write(text,
"(A,': Superbasic constraint',i6,' does not have small reduced cost. Is',1p,d15.6)")
Case, i,
udual(i)
517 call flog( trim(text), 1 )
520 write(text,
"(A,': Constraint',i6,' bas illegal basis status:',I10)")
Case, i,
ubasc(i)
521 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