-
Notifications
You must be signed in to change notification settings - Fork 2
/
ck.f
1375 lines (1350 loc) · 48.1 KB
/
ck.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CM
C->>> ----------------------------------------------> ems_ck_rsmi_da <<<
subroutine ems_ck_rsmi_da(ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'ICTVR.INC'
c include 'RLCTVR.INC'
c include 'EMSMSG.INC'
integer is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
double precision ftran_er, btran_er
call ems_ck_al_vr_st(
& ds(p_rsmi_lb),
& ds(p_rsmi_co),
& ds(p_rsmi_ub),
& is(p_st),
& ds(p_pr_act))
call ems_ck_vr_in_c(is(p_vr_in_c), is(p_st), ds)
call ems_ck_ix_o_vr(
& is(p_vr_in_r),
& is(p_vr_in_c),
& is(p_st))
call ems_ca_rand_ck_inv(.true., ftran_er, btran_er, ds, is)
call ems_ck_bc_co(
& is(p_st),
& ds(p_rsmi_co),
& is(p_vr_in_r),
& ds(p_bc_co_v),
& is(p_bc_co_ix),
& is(p_bc_co_ix_bar))
call ems_ck_pr_act_rsdu(ds, is)
call ems_ck_co_rsdu(ds, is)
return
end
subroutine ems_ck_pr_act_rsdu(ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
integer is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
double precision pr_act_rsdu_norm, rlv_pr_act_rsdu_norm
integer rl_wk_a_ix
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
call ems_g_rsmi_rl_wk_a_ix(rl_wk_a_ix)
if (rl_wk_a_ix .lt. 0) goto 8000
call ems_g_pr_act_rsdu_norm(
& ds(p_pr_act),
& is(p_st),
& ds(p_mtx_r_v),
& is(p_mtx_r_ix),
& is(p_mtx_c_sa),
& ds(p_rsmi_rl_wk_a(rl_wk_a_ix)),
& pr_act_rsdu_norm, rlv_pr_act_rsdu_norm)
call ems_fr_rsmi_rl_wk_a_ix(rl_wk_a_ix)
if (pr_act_rsdu_norm .gt. tl_pr_ifs) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9520)
& pr_act_rsdu_norm, rlv_pr_act_rsdu_norm
call ems_msg_wr_li(warn_msg_n)
else if (pr_pass_1 .eq. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9200)
call ems_msg_wr_li(rsmi_msg_n)
pr_pass_1 = 1
end if
7000 continue
return
8000 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9800)
call ems_msg_wr_li(bug_msg_n)
goto 7000
9200 format('No error in primal activity residuals')
9520 format('Primal activity residual: Absolute = ', g11.4,
& ' Relative = ', g11.4)
9800 format('RSMI workspace not available in ems_ck_pr_act_rsdu')
end
subroutine ems_ck_co_rsdu(ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
integer is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
double precision bc_co_rsdu_norm, rlv_bc_co_rsdu_norm
double precision non_bc_co_rsdu_norm, rlv_non_bc_co_rsdu_norm
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
call ems_g_co_rsdu_norm(
& ds(p_du_act),
& ds(p_mtx_r_v),
& is(p_mtx_r_ix),
& is(p_mtx_c_sa),
& ds, is,
& bc_co_rsdu_norm, rlv_bc_co_rsdu_norm,
& non_bc_co_rsdu_norm, rlv_non_bc_co_rsdu_norm)
if (bc_co_rsdu_norm .gt. tl_pr_ifs) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9520)
& bc_co_rsdu_norm, rlv_bc_co_rsdu_norm
call ems_msg_wr_li(warn_msg_n)
else if (pr_pass_1 .eq. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9200)
call ems_msg_wr_li(rsmi_msg_n)
pr_pass_1 = 1
end if
if (non_bc_co_rsdu_norm .gt. tl_pr_ifs) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9521)
& non_bc_co_rsdu_norm, rlv_non_bc_co_rsdu_norm
call ems_msg_wr_li(warn_msg_n)
else if (pr_pass_1 .eq. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9201)
call ems_msg_wr_li(rsmi_msg_n)
pr_pass_1 = 1
end if
return
9200 format('No error in basic cost residuals')
9201 format('No error in nonbasic cost residuals')
9520 format(' Basic cost residual: Absolute = ', g11.4,
& ' Relative = ', g11.4)
9521 format('Nonbasic cost residual: Absolute = ', g11.4,
& ' Relative = ', g11.4)
end
C->>> ------------------------------------------------> ems_ck_lp_da <<<
subroutine ems_ck_lp_da(ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
integer is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
if (iand(ck_msk, st_ck_bt) .ne. 0) then
call ems_ck_al_vr_st(
& ds(p_rsmi_lb),
& ds(p_rsmi_co),
& ds(p_rsmi_ub),
& is(p_st),
& ds(p_pr_act))
call ems_ck_vr_in_c(is(p_vr_in_c), is(p_st), ds)
call ems_ck_ix_o_vr(
& is(p_vr_in_r),
& is(p_vr_in_c),
& is(p_st))
end if
if (iand(ck_msk, bc_co_ck_bt) .ne. 0) then
call ems_ck_bc_co(
& is(p_st),
& ds(p_rsmi_co),
& is(p_vr_in_r),
& ds(p_bc_co_v),
& is(p_bc_co_ix),
& is(p_bc_co_ix_bar))
endif
if (iand(ck_msk, pr_act_ck_bt) .ne. 0) then
call ems_ck_pr_act_rsdu(ds, is)
endif
if ((iand(ck_msk, du_act_ck_bt) .ne. 0) .or.
& (iand(ck_msk, ed_wt_ck_bt) .ne. 0 .and.
& pc_alg .eq. pc_alg_sed)) then
call ems_ck_co_rsdu(ds, is)
call ems_ck_al_du_act_ed_wt(
& is(p_vr_in_c),
& ds(p_du_act),
& ds(p_ed_wt),
& ds, is)
endif
return
end
C->>> ---------------------------------------------> ems_ck_vr_bt_se <<<
c Reports and updates er_fd if the given bit is not set.
c
subroutine ems_ck_vr_bt_se(bt, ch3_bt_nm, er_fd,
& vr_n, vr_st, ch8_vr_bs, ch5_vr_ty, ch5_vr_wh)
implicit none
include 'EMSMSG.INC'
integer bt, vr_n, vr_st
logical er_fd
character*3 ch3_bt_nm
character*5 ch5_vr_ty, ch5_vr_wh
character*8 ch8_vr_bs
if (iand(vr_st, bt) .eq. 0) goto 8000
7000 continue
return
8000 continue
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9800)
& ch8_vr_bs, ch5_vr_ty, vr_n,
& ch5_vr_wh, ch3_bt_nm
call ems_msg_wr_li(bug_msg_n)
goto 7000
9800 format(a8, 1x, a5, ' variable ', i7, 1x, a5,
& ' should have ', a3, ' bit set')
end
C->>> ------------------------------------------> ems_ck_vr_bt_no_se <<<
c Reports and updates er_fd if the given bit is set.
c
subroutine ems_ck_vr_bt_no_se(bt, ch3_bt_nm, er_fd,
& vr_n, vr_st, ch8_vr_bs, ch5_vr_ty, ch5_vr_wh)
implicit none
include 'EMSMSG.INC'
integer bt, vr_n, vr_st
logical er_fd
character*3 ch3_bt_nm
character*5 ch5_vr_ty, ch5_vr_wh
character*8 ch8_vr_bs
if (iand(vr_st, bt) .ne. 0) goto 8000
7000 continue
return
8000 continue
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9800)
& ch8_vr_bs, ch5_vr_ty, vr_n,
& ch5_vr_wh, ch3_bt_nm
call ems_msg_wr_li(bug_msg_n)
goto 7000
9800 format(a8, 1x, a5, ' variable ', i7, 1x, a5,
& ' should not have ', a3, ' bit set')
end
C->>> ----------------------------------------------> ems_ck_wr_rsmi <<<
c Checks the indexing, status and primal activities. Writes out the
c values and status of all variables.
c
subroutine ems_ck_wr_rsmi(ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
double precision ds(0:ds_n_en_m1)
integer is(0:is_n_en_m1)
ck_msk = st_ck_bt + pr_act_ck_bt
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)n_si_it
call ems_msg_wr_li(info_msg_n)
call ems_ck_lp_da(ds, is)
c call ems_rp_al_vr_st(ds, is)
return
9000 format('Checking RSMI on iteration ', i7)
end
C->>> ------------------------------------------------> ems_ck_bc_co <<<
c Checks the costs of the basic variables.
c
subroutine ems_ck_bc_co(st, rsmi_co, vr_in_r,
& bc_co_v, bc_co_ix, bc_co_ix_bar)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'RSMICOM.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
double precision rsmi_co(0:mx_n_c+n_r)
double precision bc_co_v(0:n_r)
integer st(0:mx_n_c+n_r), vr_in_r(0:n_r)
integer bc_co_ix(0:n_r), bc_co_ix_bar(0:n_r)
integer r_n, vr_n
double precision tru_bc_co
logical er_fd
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
er_fd = .false.
if (lp_ph .eq. 1) then
do 10, r_n = 1, n_r
vr_n = vr_in_r(r_n)
if (iand(st(vr_n), ifs_bt) .eq. 0) then
tru_bc_co = pr_co_mu*rsmi_co(vr_n)
if (bc_co_v(r_n) .ne. tru_bc_co) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& vr_n, bc_co_v(r_n), tru_bc_co
call ems_msg_wr_li(bug_msg_n)
end if
else
if (iand(st(vr_n), up_bt) .ne. 0) then
tru_bc_co = -one + pr_co_mu*rsmi_co(vr_n)
if (bc_co_v(r_n) .ne. tru_bc_co) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& vr_n, bc_co_v(r_n), tru_bc_co
call ems_msg_wr_li(bug_msg_n)
end if
else
tru_bc_co = one + pr_co_mu*rsmi_co(vr_n)
if (bc_co_v(r_n) .ne. tru_bc_co) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& vr_n, bc_co_v(r_n), tru_bc_co
call ems_msg_wr_li(bug_msg_n)
end if
end if
end if
10 continue
else
do 20, r_n = 1, n_r
vr_n = vr_in_r(r_n)
tru_bc_co = pr_co_mu*rsmi_co(vr_n)
if (bc_co_v(r_n) .ne. tru_bc_co) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& vr_n, bc_co_v(r_n), tru_bc_co
call ems_msg_wr_li(bug_msg_n)
end if
20 continue
end if
if (er_fd) then
CM IF (emsol_deb .EQ. 1) THEN
C? call ems_dump
CM ENDIF
call ems_se_bc_co(st, rsmi_co, vr_in_r,
& bc_co_v, bc_co_ix, bc_co_ix_bar)
fresh_pc = .true.
else if (pr_pass_1 .eq. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9010)
call ems_msg_wr_li(info_msg_n)
pr_pass_1 = 1
end if
return
9000 format('Variable number ', i7, ' has basic cost of ', g11.4,
& ' rather than ', g11.4)
9010 format('No error in the basic costs')
end
C->>> ---------------------------------------------> ems_ck_al_vr_st <<<
c Check the status of all the variables.
c
subroutine ems_ck_al_vr_st(rsmi_lb, rsmi_co, rsmi_ub, st, pr_act)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
double precision rsmi_lb(0:mx_n_c+n_r)
double precision rsmi_co(0:mx_n_c+n_r)
double precision rsmi_ub(0:mx_n_c+n_r)
double precision pr_act(0:mx_n_c+n_r)
integer st(0:mx_n_c+n_r)
logical ems_ck_vr_st
integer ix, vr_n
logical er_fd
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
er_fd = .false.
do 10, ix = 1, n_r+n_c
vr_n = ix
if (ix .gt. n_c) vr_n = ix + mx_n_c-n_c
er_fd = ems_ck_vr_st(vr_n,
& rsmi_lb(vr_n), rsmi_co(vr_n), rsmi_ub(vr_n),
& st(vr_n), pr_act(vr_n)) .or. er_fd
10 continue
if (pr_pass_1 .eq. 0 .and. .not. er_fd) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9200)
call ems_msg_wr_li(rsmi_msg_n)
pr_pass_1 = 1
end if
return
9200 format('No error in status of variables')
end
C->>> ------------------------------------------------> ems_ck_vr_st <<<
c Checks variable's bounds and activity against its status.
c
logical function ems_ck_vr_st(vr_n, rsmi_lb, rsmi_co, rsmi_ub,
& st, pr_act)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
integer vr_n, st
double precision rsmi_lb, rsmi_co, rsmi_ub, pr_act
double precision rsdu
logical er_fd
er_fd = .false.
if (iand(st, alt_bt) .eq. 0) then
c
c Variable is Standard
c
c Check the bounds
c
if (iand(st, lb_bt) .eq. 0) then
c
c Variable has no lower bound: make sure it it is infinite
c
if (rsmi_lb .gt. -inf) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9010)
& 'Std', vr_n, 'lb ', 'lb ', rsmi_lb
call ems_msg_wr_li(bug_msg_n)
endif
else
c
c Variable has a lower bound: make sure it it is finite
c
if (rsmi_lb .le. -inf) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9011)
& 'Std', vr_n, 'lb ', 'lb ', rsmi_lb
call ems_msg_wr_li(bug_msg_n)
endif
endif
if (iand(st, ub_bt) .eq. 0) then
c
c Variable has no upper bound: make sure it it is infinite
c
if (rsmi_ub .lt. inf) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9010)
& 'Std', vr_n, 'ub ', 'ub ', rsmi_ub
call ems_msg_wr_li(bug_msg_n)
endif
else
c
c Variable has an upper bound: make sure it it is finite
c
if (rsmi_ub .ge. inf) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9011)
& 'Std', vr_n, 'ub ', 'ub ', rsmi_ub
call ems_msg_wr_li(bug_msg_n)
endif
endif
c
c Check that the bits set are consistent (with the primal activity).
c
if (iand(st, ub_bt) .eq. 0) then
if (iand(st, lb_bt) .eq. 0) then
c
c A FR variable: should have up:dn:fs = 1:1:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'FR ', 'Btw ')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'FR ', 'Btw ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'FR ', 'Btw ')
else
c
c A LB variable:
c
rsdu = rsmi_lb - pr_act
if (rsdu .gt. tl_pr_ifs) then
c
c below its bound should have up:dn:fs = 1:0:0
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'LB ', 'Bw_Lb')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'LB ', 'Bw_Lb')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'LB ', 'Bw_Lb')
else if (iand(st, bc_bt) .eq. 0 .and.
& rsdu .ge. -tl_pr_ifs) then
c
c nonbasic at its bound should have up:dn:fs = 1:0:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'LB ', 'At_Lb')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'LB ', 'At_Lb')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Nonbasic', 'LB ', 'At_Lb')
else
c
c basic at/above or nonbasic above its bound should have
c up:dn:fs = 1:1:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'LB ', 'Btw ')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'LB ', 'Btw ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'LB ', 'Btw ')
endif
endif
else
if (iand(st, lb_bt) .eq. 0) then
c
c A UB variable:
c
rsdu = pr_act - rsmi_ub
if (rsdu .gt. tl_pr_ifs) then
c
c above its bound should have up:dn:fs = 0:1:0
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'UB ', 'Ab_Ub')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'UB ', 'Ab_Ub')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'UB ', 'Ab_Ub')
else if (iand(st, bc_bt) .eq. 0 .and.
& rsdu .ge. -tl_pr_ifs) then
c
c nonbasic at its bound should have up:dn:fs = 0:1:1
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'UB ', 'At_UB')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'UB ', 'At_UB')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Nonbasic', 'UB ', 'At_UB')
else
c
c basic at/below or nonbasic below its bound should have
c up:dn:fs = 1:1:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'UB ', 'Btw ')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'UB ', 'Btw ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'UB ', 'Btw ')
endif
else if (rsmi_lb .ne. rsmi_ub) then
c
c A LB/UB variable:
c
rsdu = max(rsmi_lb-pr_act, pr_act-rsmi_ub)
if (rsdu .gt. tl_pr_ifs) then
if (pr_act .lt. rsmi_lb) then
c
c below its lower bound should have up:dn:fs = 1:0:0
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Bw_Lb')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Bw_Lb')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Bw_Lb')
else
c
c above its upper bound should have up:dn:fs = 0:1:0
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Ab_Ub')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Ab_Ub')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Ab_Ub')
endif
else if (iand(st, bc_bt) .eq. 0 .and.
& rsdu .ge. -tl_pr_ifs) then
if (two*pr_act .lt. rsmi_lb+rsmi_ub) then
c
c nonbasic at its lower bound should have up:dn:fs = 1:0:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_Lb')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_Lb')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_Lb')
else
c
c nonbasic at its upper bound should have up:dn:fs = 0:1:1
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_UB')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_UB')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Nonbasic', 'LB/UB', 'At_UB')
endif
else
c
c basic at/between or nonbasic between its bounds should have
c up:dn:fs = 1:1:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Btw ')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Btw ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'LB/UB', 'Btw ')
endif
else
c
c A FX variable:
c
rsdu = max(rsmi_lb-pr_act, pr_act-rsmi_ub)
if (rsdu .gt. tl_pr_ifs) then
if (pr_act .lt. rsmi_lb) then
c
c below its lower bound should have up:dn:fs = 1:0:0
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'FX ', 'Bw_Lb')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'FX ', 'Bw_Lb')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'FX ', 'Bw_Lb')
else
c
c above its upper bound should have up:dn:fs = 0:1:0
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'FX ', 'Ab_Ub')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'FX ', 'Ab_Ub')
call ems_ck_vr_bt_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'FX ', 'Ab_Ub')
endif
else
if (iand(st, bc_bt) .eq. 0) then
c
c Nonbasic at its fixed value should have up:dn:fs = 0:0:1
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'FX ', 'Fx ')
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'FX ', 'Fx ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Nonbasic', 'FX ', 'Fx ')
else
c
c Basic at its fixed value should have up:dn:fs = 1:1:1
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, 'Basic ', 'FX ', 'Fx ')
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, 'Basic ', 'FX ', 'Fx ')
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, 'Basic ', 'FX ', 'Fx ')
endif
endif
endif
endif
else if (iand(st, bp_bt) .ne. 0) then
c
c Variable is BP
c
c Should have the fs bit set:
c
call ems_ck_vr_bt_no_se(ifs_bt, 'ifs', er_fd,
& vr_n, st, ' ', 'BP ', ' ')
if (iand(st, lb_bt) .ne. 0) then
c
c Variable is at/above its break point.
c
c lb:co:ub are bp:uco:lco-uco
c
c The ub bit should not be set
c
call ems_ck_vr_bt_no_se(ub_bt, 'ub ', er_fd,
& vr_n, st, ' ', 'BP ', 'Ab_Bp')
c
c The up bit should be set
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'BP ', 'Ab_Bp')
rsdu = rsmi_lb - pr_act
if (rsdu .gt. tl_pr_ifs) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9020)
& vr_n, rsdu
call ems_msg_wr_li(bug_msg_n)
endif
if (iand(st, bc_bt) .eq. 0 .and. rsdu .ge. -tl_pr_ifs) then
c
c If nonbasic and at the break point then the dn bit should not be
c set.
c
call ems_ck_vr_bt_no_se(dn_bt, 'dn ', er_fd,
& vr_n, st, 'Nonbasic', 'BP ', 'Ab_Bp')
else
c
c If basic or above the break point then the dn bit should be set.
c
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'BP ', 'Btw ')
endif
else
c
c Variable is at/below its break point.
c
c lb:co:ub are uco-lco:lco:bp
c
c The lb bit should not be set
c
call ems_ck_vr_bt_no_se(lb_bt, 'lb ', er_fd,
& vr_n, st, ' ', 'BP ', 'Bw_Bp')
c
c The dn bit should be set
c
call ems_ck_vr_bt_se( dn_bt, 'dn ', er_fd,
& vr_n, st, ' ', 'BP ', 'Bw_Bp')
rsdu = pr_act - rsmi_ub
if (rsdu .gt. tl_pr_ifs) then
er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9021)
& vr_n, rsdu
call ems_msg_wr_li(bug_msg_n)
endif
if (iand(st, bc_bt) .eq. 0 .and. rsdu .ge. -tl_pr_ifs) then
c
c If nonbasic and at the break point then the up bit should not be
c set.
c
call ems_ck_vr_bt_no_se(up_bt, 'up ', er_fd,
& vr_n, st, 'Nonbasic', 'BP ', 'Bw_Bp')
else
c
c If basic or above the break point then the up bit should be set.
c
call ems_ck_vr_bt_se( up_bt, 'up ', er_fd,
& vr_n, st, ' ', 'BP ', 'Btw ')
endif
endif
else
c
c Variable is PWL
c
endif
ems_ck_vr_st = er_fd
return
9010 format(11x, a3, ' variable ', i7, ' has ', a3,
& ' bit not set but ', a3, ' = ', g11.4)
9011 format(11x, a3, ' variable ', i7, ' has ', a3,
& ' bit set but ', a3, ' = ', g11.4)
9020 format(11x, 'BP variable ', i7,
& ' has lb bit set but act-bp = ', g11.4)
9021 format(11x, 'BP variable ', i7,
& ' has ub bit set but bp-act = ', g11.4)
end
C->>> --------------------------------------> ems_ck_al_du_act_ed_wt <<<
c Checks the dual activities (and/or edge weights if using steepest
c edge) of all the variables for pricing,
c writes a message for eack error or an OK message if there is none.
c
subroutine ems_ck_al_du_act_ed_wt(vr_in_c, du_act, ed_wt, ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'RSMICOM.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
integer vr_in_c(-vr_in_c_n_sn:n_c), is(0:is_n_en_m1)
double precision ed_wt(0:mx_n_c+n_r)
double precision du_act(0:mx_n_c+n_r)
double precision ds(0:ds_n_en_m1)
double precision ems_scpr
integer c_n, vr_n, null
double precision alt_du_act, du_act_er
double precision tru_ed_wt, ed_wt_er
double precision ph_1_du_act
logical du_act_er_fd
logical ed_wt_er_fd
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
du_act_er_fd = .false.
ed_wt_er_fd = .false.
do 10, c_n = 1, vr_in_c(os_lg_in_c_l_pc_p)
vr_n = vr_in_c(c_n)
call ems_g_rhs(1, vr_n, ds(p_pv_c_v), n_r+1, ds, is)
call ems_ftran(ds(p_pv_c_v), n_r+1, ds, is)
if (iand(ck_msk, du_act_ck_bt) .ne. 0) then
call ems_g_alt_du_act(
& 1, vr_n,
& is(p_st),
& is(p_vr_in_r),
& ds(p_rsmi_co),
& ds(p_bc_co_v),
& is(p_bc_co_ix),
& ds(p_pv_c_v),
& du_act(vr_n), alt_du_act, ph_1_du_act)
if (abs(du_act(vr_n)) .gt. tl_du_ifs) then
du_act_er = abs((du_act(vr_n)-alt_du_act)/du_act(vr_n))
else
du_act_er = abs(du_act(vr_n)-alt_du_act)
end if
if (du_act_er .gt. tl_du_ifs) then
du_act_er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9510)
& vr_n-mx_n_c, 'Dual activity:',
& 'BTRAN + PRICE', du_act(vr_n),
& ' FTRAN', alt_du_act, du_act_er
call ems_msg_wr_li(warn_msg_n)
end if
endif
if (iand(ck_msk, ed_wt_ck_bt) .ne. 0) then
if (pc_alg .eq. pc_alg_sed) then
tru_ed_wt =
& ems_scpr(one, ds(p_pv_c_v), ds(p_pv_c_v), n_r)*half
ed_wt_er = (tru_ed_wt-ed_wt(vr_n))/ed_wt(vr_n)
if (abs(ed_wt_er) .gt. tl_du_ifs) then
ed_wt_er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9510)
& vr_n-mx_n_c, 'Stpst edge wt:',
& ' U_STPST_ED_WT', ed_wt(vr_n),
& ' FTRAN', tru_ed_wt, ed_wt_er
call ems_msg_wr_li(warn_msg_n)
end if
endif
endif
nw_eta_l_ix = n_r+1
call ems_ze_pv_c_v(ds(p_pv_c_v), null)
10 continue
do 20, c_n = vr_in_c(os_struc_in_c_f_p_m1) + 1,
& vr_in_c(os_struc_in_c_l_pc_p)
vr_n = vr_in_c(c_n)
call ems_g_rhs(1, vr_n, ds(p_pv_c_v), n_r+1, ds, is)
call ems_ftran(ds(p_pv_c_v), n_r+1, ds, is)
if (iand(ck_msk, du_act_ck_bt) .ne. 0) then
call ems_g_alt_du_act(
& 1, vr_n,
& is(p_st),
& is(p_vr_in_r),
& ds(p_rsmi_co),
& ds(p_bc_co_v),
& is(p_bc_co_ix),
& ds(p_pv_c_v),
& du_act(vr_n), alt_du_act, ph_1_du_act)
if (abs(du_act(vr_n)) .gt. tl_du_ifs) then
du_act_er = abs((du_act(vr_n)-alt_du_act)/du_act(vr_n))
else
du_act_er = abs(du_act(vr_n)-alt_du_act)
end if
if (du_act_er .gt. tl_du_ifs) then
du_act_er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9520)
& vr_n, 'Dual activity:',
& 'BTRAN + PRICE', du_act(vr_n),
& ' FTRAN', alt_du_act, du_act_er
call ems_msg_wr_li(warn_msg_n)
end if
endif
if (iand(ck_msk, ed_wt_ck_bt) .ne. 0) then
if (pc_alg .eq. pc_alg_sed) then
tru_ed_wt =
& ems_scpr(one, ds(p_pv_c_v), ds(p_pv_c_v), n_r)*half
ed_wt_er = (tru_ed_wt-ed_wt(vr_n))/ed_wt(vr_n)
if (abs(ed_wt_er) .gt. tl_du_ifs) then
ed_wt_er_fd = .true.
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9520)
& vr_n, 'Stpst edge wt:',
& ' U_STPST_ED_WT', ed_wt(vr_n),
& ' FTRAN', tru_ed_wt, ed_wt_er
call ems_msg_wr_li(warn_msg_n)
end if
endif
endif
nw_eta_l_ix = n_r+1
call ems_ze_pv_c_v(ds(p_pv_c_v), null)
20 continue
if (pr_pass_1 .eq. 0) then
if (iand(ck_msk, du_act_ck_bt) .ne. 0 .and.
& .not.du_act_er_fd) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9210)
call ems_msg_wr_li(rsmi_msg_n)
endif
if (iand(ck_msk, ed_wt_ck_bt) .ne. 0 .and.
& .not.ed_wt_er_fd) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9220)
call ems_msg_wr_li(rsmi_msg_n)
endif
pr_pass_1 = 1
end if
if (iand(ck_msk, ze_a_ck_bt) .ne. 0)
& call ems_ck_ze_rl_a(n_r, ds(p_pv_c_v))
return
9210 format('No error in the dual activities')
9220 format('No error in the edge weights')
9510 format('Row ', i7, 1x, a14,
& 2(' From ', a14, ' = ', g11.4), ' |Rel. error| = ', g11.4)
9520 format('Column ', i7, 1x, a14,
& 2(' From ', a14, ' = ', g11.4), ' |Rel. error| = ', g11.4)
end
C->>> ----------------------------------------------> ems_ck_ix_o_vr <<<
c Checks that the indices of variables sored in st correspond to the
c vr_in_r and vr_in_c supplied.
c
subroutine ems_ck_ix_o_vr(
& vr_in_r,
& vr_in_c,
& st)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
c include 'RSMICS.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
integer vr_in_r(0:n_r)
integer vr_in_c(-vr_in_c_n_sn:n_c)
integer st(0:mx_n_c+n_r)
integer r_n, c_n, vr_n, ix_n
logical er_fd
integer pr_pass_1
save pr_pass_1
data pr_pass_1/0/
er_fd = .false.
do 10, r_n = 1, n_r
vr_n = vr_in_r(r_n)
if (iand(st(vr_n), bc_bt) .ne. bc_bt) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9900)vr_n
call ems_msg_wr_li(bug_msg_n)
er_fd = .true.
st(vr_n) = st(vr_n) + bc_bt
end if
ix_n = iand(st(vr_n), mx_mx_ml_a_dim)
if (ix_n .ne. r_n) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9910)
& vr_n, ix_n, r_n
call ems_msg_wr_li(bug_msg_n)
er_fd = .true.
st(vr_n) = st(vr_n) - ix_n + r_n
end if
10 continue
do 20, c_n = 1, vr_in_c(os_vr_in_c_l_p)
vr_n = vr_in_c(c_n)
if (iand(st(vr_n), bc_bt) .ne. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9920)vr_n
call ems_msg_wr_li(bug_msg_n)
er_fd = .true.
st(vr_n) = st(vr_n) - bc_bt
end if
ix_n = iand(st(vr_n), mx_mx_ml_a_dim)
if (ix_n .ne. c_n) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9930)
& vr_n, ix_n, c_n
call ems_msg_wr_li(bug_msg_n)
er_fd = .true.
st(vr_n) = st(vr_n) - ix_n + c_n
end if
20 continue
if (er_fd) then
CM IF (emsol_deb .EQ. 1) THEN
C? call ems_dump
CM ENDIF
else if (pr_pass_1 .eq. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9940)
call ems_msg_wr_li(rsmi_msg_n)
pr_pass_1 = 1
end if
return
9900 format('Basic variable ', i7, ' does not have basic bit set')
9910 format('Basic variable ', i7, ' has index ', i7, ' not ', i7)
9920 format('Nonbasic variable ', i7, ' has basic bit set')
9930 format('Nonbasic variable ', i7, ' has index ', i7, ' not ', i7)
9940 format('Indexing of variables is correct')
end