-
Notifications
You must be signed in to change notification settings - Fork 2
/
crsh.f
2618 lines (2571 loc) · 88.4 KB
/
crsh.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_ca_crsh_ml <<<
c Call the routines to allocate space for, perform and deallocate
c space for a symbolic crash.
c
subroutine ems_ca_crsh_ml(crsh_ty, ds, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
include 'CRASH.INC'
integer crsh_ty, is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
c integer rl_wk_a_ix
c double precision ftran_rsdu_norm, btran_rsdu_norm
integer rl_wk_a_ix1
integer rl_wk_a_ix2
integer i_wk_a_ix1
integer i_wk_a_ix2
if (crsh_ty .le. 1) then
Call ems_ltssf_iz_blk_crsh(is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
call ems_iz_crsh_com(crsh_ty)
tl_crsh_abs_pv_v = usr_tl_crsh_abs_pv_v
tl_crsh_rlv_pv_v = usr_tl_crsh_rlv_pv_v
call ems_iz_ltssf_crsh_vr_ty(crsh_ty,
& ds(p_lbc),
& ds(p_ubc),
& is(p_st),
& is(p_crsh_r_ty),
& is(p_crsh_c_ty))
call ems_g_rsmi_rl_wk_a_ix(rl_wk_a_ix1)
if (rl_wk_a_ix1 .lt. 0) goto 8000
call ems_g_rsmi_rl_wk_a_ix(rl_wk_a_ix2)
if (rl_wk_a_ix2 .lt. 0) goto 8000
call ems_g_rsmi_i_wk_a_ix(i_wk_a_ix1)
if (i_wk_a_ix1 .lt. 0) goto 8000
call ems_g_rsmi_i_wk_a_ix(i_wk_a_ix2)
if (i_wk_a_ix2 .lt. 0) goto 8000
Call ems_ltssf_crsh(
& ds(p_lbc),
& ds(p_ubc),
& is(p_st),
& ds(p_pr_act),
& is(p_vr_in_r),
& is(p_vr_in_c+vr_in_c_n_sn),
& ds(p_mtx_r_v),
& is(p_mtx_r_ix),
& is(p_mtx_c_sa),
& is(p_crsh_r_ty),
& is(p_crsh_r_pri_lkb),
& is(p_crsh_r_pri_lkf),
& is(p_crsh_c_ty),
& is(p_crsh_r_n_act_en),
& is(p_crsh_r_n_act_en_hdr),
& is(p_crsh_r_n_act_en_lkb),
& is(p_crsh_r_n_act_en_lkf),
& is(p_crsh_c_n_act_en),
& ds(p_crsh_mtx_c_mx_abs_v),
& ds(p_crsh_mtx_c_v),
& is(p_crsh_mtx_c_ix),
& is(p_crsh_mtx_r_sa),
& is(p_crsh_r_st),
& is(p_crsh_c_st),
& is(p_rsmi_i_wk_a(i_wk_a_ix1)),
& is(p_rsmi_i_wk_a(i_wk_a_ix2)),
& ds(p_rsmi_rl_wk_a(rl_wk_a_ix1)),
& ds(p_rsmi_rl_wk_a(rl_wk_a_ix2)))
call ems_fr_rsmi_rl_wk_a_ix(rl_wk_a_ix1)
call ems_fr_rsmi_rl_wk_a_ix(rl_wk_a_ix2)
call ems_fr_rsmi_i_wk_a_ix(i_wk_a_ix1)
call ems_fr_rsmi_i_wk_a_ix(i_wk_a_ix2)
c call ems_rsmi_inv(ds, is)
c if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
c call ems_g_rsmi_rl_wk_a_ix(rl_wk_a_ix)
c if (rl_wk_a_ix .lt. 0) goto 8000
c call ems_g_rand_tran_rsdu_norm(.true.,
c & is(p_vr_in_r),
c & ds(p_mtx_r_v), is(p_mtx_r_ix), is(p_mtx_c_sa),
c & ds(p_pv_c_v),
c & ds(p_rsmi_rl_wk_a(rl_wk_a_ix)),
c & ftran_rsdu_norm, btran_rsdu_norm, is, ds)
c call ems_fr_rsmi_rl_wk_a_ix(rl_wk_a_ix)
c if (max(ftran_rsdu_norm, btran_rsdu_norm) .gt.
c & tl_iz_bs_tran_er) then
c if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9510)
c & ftran_rsdu_norm, btran_rsdu_norm
c call ems_msg_wr_li(warn_msg_n)
c endif
else
call ems_ltsf_iz_blk_crsh(is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
call ems_iz_crsh_com(crsh_ty)
call ems_ltsf_crsh(
& ds(p_lbc),
& ds(p_ubc),
& is(p_st),
& is(p_vr_in_r),
& is(p_vr_in_c+vr_in_c_n_sn),
& is(p_mtx_r_ix),
& is(p_mtx_c_sa),
& is(p_crsh_r_ty),
& is(p_crsh_c_ty),
& is(p_crsh_r_n_act_en),
& is(p_crsh_c_n_act_en),
& is(p_crsh_mtx_c_ix),
& is(p_crsh_mtx_r_sa),
& is(p_crsh_r_st),
& is(p_crsh_c_st))
endif
call ems_rm_blk_crsh(is)
c
c Indicate that the following are not correct for the model:
c
c vr_in_c, INVERT, status/primal activities, basic primal
c activities, edge weights and row-wise representation of matrix
c columns being priced.
c
ml_da_st_msk = ml_da_st_msk
& - iand(ml_da_st_msk, ml_da_st_vr_in_c)
& - iand(ml_da_st_msk, ml_da_st_inv)
& - iand(ml_da_st_msk, ml_da_st_vr_st_fm_act)
& - iand(ml_da_st_msk, ml_da_st_bc_pr_act)
& - iand(ml_da_st_msk, ml_da_st_ed_wt)
& - iand(ml_da_st_msk, ml_da_st_r_mtx)
7000 continue
c 7100 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
c 9510 format('Residual errors of ',
c & g11.4, ' solving A.x = b and ',
c & g11.4, ' solving A^x = b',
c & ' indicate that the basis is ill-conditioned')
9800 format('RSMI workspace not available in ems_ca_crsh_ml')
end
C->>> -----------------------------------------------> ems_ltsf_crsh <<<
c Perform LTSF crash.
c
subroutine ems_ltsf_crsh(
& lbc,
& ubc,
& st,
& vr_in_r,
& vr_in_c,
& mtx_r_ix,
& mtx_c_sa,
& crsh_r_ty,
& crsh_c_ty,
& crsh_r_n_act_en,
& crsh_c_n_act_en,
& crsh_mtx_c_ix,
& crsh_mtx_r_sa,
& crsh_r_st,
& crsh_c_st)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'EMSPM.INC'
include 'CRASH.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
double precision lbc(0:mx_n_c+n_r)
double precision ubc(0:mx_n_c+n_r)
integer st(0:mx_n_c+n_r)
integer vr_in_r(0:n_r)
integer vr_in_c(0:n_c)
integer mtx_r_ix(0:n_a_el)
integer mtx_c_sa(0:n_c+1)
integer crsh_r_ty(0:n_r)
integer crsh_c_ty(0:n_c)
integer crsh_r_n_act_en(0:n_r)
integer crsh_c_n_act_en(0:n_c)
integer crsh_mtx_c_ix(0:n_a_el)
integer crsh_mtx_r_sa(0:n_r+1)
integer crsh_r_st(0:n_r)
integer crsh_c_st(0:n_c)
CM IF (emsol_dev .EQ. 1) THEN
C? integer ems_i_t_i_pct
C? integer pct
CM ENDIF
integer r_n, c_n, vr_n, el_n, r_el_n, lg_vr_n
integer cz_r_n, r_pri_fn_v, mx_r_pri_fn_v
integer cz_c_n, c_pri_fn_v, mx_c_pri_fn_v
integer vr_st
integer n_vr_in_r, n_vr_in_c
logical ze_fs
integer n_crsh_bs_cg, crsh_vr_ty
ze_fs = iand(crsh_msk, crsh_msk_ze_fs_bt) .ne. 0
do 2, crsh_vr_ty = crsh_f_vr_ty, crsh_l_vr_ty
crsh_vr_ty_og_n_r(crsh_vr_ty) = 0
crsh_vr_ty_og_n_c(crsh_vr_ty) = 0
crsh_vr_ty_rm_n_r(crsh_vr_ty) = 0
crsh_vr_ty_add_n_c(crsh_vr_ty) = 0
2 continue
do 10, r_n = 1, n_r
vr_n = mx_n_c + r_n
vr_st = st(vr_n)
if (ubc(vr_n) .ge. inf) then
if (lbc(vr_n) .le. -inf) then
c FR:
crsh_r_ty(r_n) = crsh_vr_ty_fr
else
c LB:
crsh_r_ty(r_n) = crsh_vr_ty_1_sd
if (ze_fs .and. lbc(vr_n) .le. zero)
& crsh_r_ty(r_n) = crsh_vr_ty_1_sd_ze_fs
endif
else
if (lbc(vr_n) .le. -inf) then
c UB:
crsh_r_ty(r_n) = crsh_vr_ty_1_sd
if (ze_fs .and. ubc(vr_n) .ge. zero)
& crsh_r_ty(r_n) = crsh_vr_ty_1_sd_ze_fs
else
if (lbc(vr_n) .ne. ubc(vr_n)) then
c LB/UB:
crsh_r_ty(r_n) = crsh_vr_ty_2_sd
if (ze_fs .and.
& lbc(vr_n) .le. zero .and.
& ubc(vr_n) .ge. zero)
& crsh_r_ty(r_n) = crsh_vr_ty_2_sd_ze_fs
else
c FX:
crsh_r_ty(r_n) = crsh_vr_ty_fx
if (ze_fs .and.
& lbc(vr_n) .le. zero .and.
& ubc(vr_n) .ge. zero)
& crsh_r_ty(r_n) = crsh_vr_ty_fx_ze_fs
endif
endif
endif
if (crsh_r_ty(r_n) .eq. crsh_vr_ty_fr) then
crsh_r_st(r_n) = crsh_vr_st_no_act
else
crsh_r_st(r_n) = crsh_vr_st_act
endif
c
c Ensure that the logical is basic.
c
st(vr_n) = ior(vr_st, bc_vr_bs_st)
c
c Initialise the count for later accumulation
c
crsh_r_n_act_en(r_n) = 0
c
c Keep a count of the original number of rows of each type
c
crsh_vr_ty_og_n_r(crsh_r_ty(r_n)) =
& crsh_vr_ty_og_n_r(crsh_r_ty(r_n)) + 1
10 continue
do 30, c_n = 1, n_c
vr_n = c_n
vr_st = st(vr_n)
if (ubc(vr_n) .ge. inf) then
if (lbc(vr_n) .le. -inf) then
c FR:
crsh_c_ty(c_n) = crsh_vr_ty_fr
else
c LB:
crsh_c_ty(c_n) = crsh_vr_ty_1_sd
if (ze_fs .and. lbc(vr_n) .le. zero)
& crsh_c_ty(c_n) = crsh_vr_ty_1_sd_ze_fs
endif
else
if (lbc(vr_n) .le. -inf) then
c UB:
crsh_c_ty(c_n) = crsh_vr_ty_1_sd
if (ze_fs .and. ubc(vr_n) .ge. zero)
& crsh_c_ty(c_n) = crsh_vr_ty_1_sd_ze_fs
else
if (lbc(vr_n) .ne. ubc(vr_n)) then
c LB/UB:
crsh_c_ty(c_n) = crsh_vr_ty_2_sd
if (ze_fs .and.
& lbc(vr_n) .le. zero .and.
& ubc(vr_n) .ge. zero)
& crsh_c_ty(c_n) = crsh_vr_ty_2_sd_ze_fs
else
c FX:
crsh_c_ty(c_n) = crsh_vr_ty_fx
if (ze_fs .and.
& lbc(vr_n) .le. zero .and.
& ubc(vr_n) .ge. zero)
& crsh_c_ty(c_n) = crsh_vr_ty_fx_ze_fs
endif
endif
endif
if (crsh_c_ty(c_n) .eq. crsh_vr_ty_fx) then
crsh_c_st(c_n) = crsh_vr_st_no_act
else
crsh_c_st(c_n) = crsh_vr_st_act
endif
crsh_c_n_act_en(c_n) = 0
c
c Ensure that the structural is nonbasic.
c
st(vr_n) = vr_st - iand(vr_st, su_vr_bs_bt) + non_bc_vr_bs_st
c
c Keep a count of the original number of columns of each type
c
crsh_vr_ty_og_n_c(crsh_c_ty(c_n)) =
& crsh_vr_ty_og_n_c(crsh_c_ty(c_n)) + 1
if (crsh_c_ty(c_n) .eq. crsh_vr_ty_fx) goto 30
do 20, el_n = mtx_c_sa(c_n), mtx_c_sa(c_n+1)-1
r_n = mtx_r_ix(el_n)
if (crsh_r_ty(r_n) .eq. crsh_vr_ty_fr) goto 20
crsh_c_n_act_en(c_n) = crsh_c_n_act_en(c_n) + 1
crsh_r_n_act_en(r_n) = crsh_r_n_act_en(r_n) + 1
20 continue
if (crsh_c_n_act_en(c_n) .eq. 0) then
crsh_c_st(c_n) = crsh_vr_st_no_act
c write(crsh_ou_cn, 9400)'Col', c_n
endif
30 continue
crsh_mtx_r_sa(1) = 1
do 40, r_n = 1, n_r
crsh_mtx_r_sa(r_n+1) =
& crsh_mtx_r_sa(r_n) + crsh_r_n_act_en(r_n)
if (crsh_r_n_act_en(r_n) .eq. 0) then
crsh_r_st(r_n) = crsh_vr_st_no_act
c write(crsh_ou_cn, 9400)'Row', r_n
endif
40 continue
c
c Used to get infeasible basis for FIT2P.
c
c do 60, c_n = n_c, 1, -1
c
do 60, c_n = 1, n_c
if (crsh_c_ty(c_n) .eq. crsh_vr_ty_fx) goto 60
do 50, el_n = mtx_c_sa(c_n), mtx_c_sa(c_n+1)-1
r_n = mtx_r_ix(el_n)
crsh_mtx_c_ix(crsh_mtx_r_sa(r_n)) = c_n
crsh_mtx_r_sa(r_n) = crsh_mtx_r_sa(r_n) + 1
50 continue
60 continue
do 70, r_n = 1, n_r
crsh_mtx_r_sa(r_n) = crsh_mtx_r_sa(r_n) - crsh_r_n_act_en(r_n)
70 continue
CM IF (emsol_dev .EQ. 1) THEN
C? write(crsh_ou_cn, 9000)
C? write(crsh_ou_cn, 9010)
C? call ems_rp_crsh_vr_ty(crsh_ou_cn, st, crsh_r_ty, crsh_c_ty)
CM ENDIF
n_crsh_bs_cg = 0
c write(crsh_ou_cn, 9050)
c call ems_flush(crsh_ou_cn)
100 continue
CM IF (emsol_dev .EQ. 1) THEN
C? call ems_rp_crsh_act_mtx(crsh_ou_cn,
C? & crsh_r_n_act_en,
C? & crsh_c_n_act_en,
C? & crsh_r_ty,
C? & crsh_c_ty,
C? & crsh_r_st,
C? & crsh_c_st,
C? & crsh_mtx_c_ix, crsh_mtx_r_sa,
C? & mtx_r_ix, mtx_c_sa)
CM ENDIF
cz_r_n = 0
mx_r_pri_fn_v = -i_inf
c write(crsh_ou_cn, 9100)
do 110, r_n = 1, n_r
if (crsh_r_st(r_n) .eq. crsh_vr_st_no_act) go to 110
r_pri_fn_v = crsh_r_ty_pri_v(crsh_r_ty(r_n)) -
& crsh_fn_dn*crsh_r_n_act_en(r_n)
if (r_pri_fn_v .gt. mx_r_pri_fn_v) then
cz_r_n = r_n
mx_r_pri_fn_v = r_pri_fn_v
endif
c write(crsh_ou_cn, 9110)r_n,
c & crsh_r_n_act_en(r_n),
c & ch3_crsh_vr_ty(crsh_r_ty(r_n)),
c & crsh_r_ty_pri_v(crsh_r_ty(r_n)),
c & r_pri_fn_v,
c & cz_r_n,
c & mx_r_pri_fn_v
110 continue
if (cz_r_n .eq. 0) goto 1000
c write(crsh_ou_cn, 9110)cz_r_n,
c & crsh_r_n_act_en(cz_r_n),
c & ch3_crsh_vr_ty(crsh_r_ty(cz_r_n)),
c & crsh_r_ty_pri_v(crsh_r_ty(cz_r_n)),
c & mx_r_pri_fn_v
cz_c_n = 0
mx_c_pri_fn_v = -i_inf
c write(crsh_ou_cn, 9120)
c if (cz_r_n .gt. 1500) then
do 120, el_n = crsh_mtx_r_sa(cz_r_n), crsh_mtx_r_sa(cz_r_n+1)-1
c_n = crsh_mtx_c_ix(el_n)
if (crsh_c_st(c_n) .eq. crsh_vr_st_no_act) go to 120
c_pri_fn_v = crsh_c_ty_pri_v(crsh_c_ty(c_n)) -
& crsh_fn_dn*crsh_c_n_act_en(c_n)
if (c_pri_fn_v .gt. mx_c_pri_fn_v) then
cz_c_n = c_n
mx_c_pri_fn_v = c_pri_fn_v
endif
c write(crsh_ou_cn, 9110)c_n,
c & crsh_c_n_act_en(c_n),
c & ch3_crsh_vr_ty(crsh_c_ty(c_n)),
c & crsh_c_ty_pri_v(crsh_c_ty(c_n)),
c & c_pri_fn_v,
c & cz_c_n,
c & mx_c_pri_fn_v
120 continue
c else
c do 121, el_n =
c & crsh_mtx_r_sa(cz_r_n+1)-1,
c & crsh_mtx_r_sa(cz_r_n), -1
c c_n = crsh_mtx_c_ix(el_n)
c if (crsh_c_st(c_n) .eq. crsh_vr_st_no_act) go to 121
c c_pri_fn_v = crsh_c_ty_pri_v(crsh_c_ty(c_n)) -
c & crsh_fn_dn*crsh_c_n_act_en(c_n)
c if (c_pri_fn_v .gt. mx_c_pri_fn_v) then
c cz_c_n = c_n
c mx_c_pri_fn_v = c_pri_fn_v
c endif
c 121 continue
c endif
if (cz_c_n .eq. 0) goto 8000
c write(crsh_ou_cn, 9110)cz_c_n,
c & crsh_c_n_act_en(cz_c_n),
c & ch3_crsh_vr_ty(crsh_c_ty(cz_c_n)),
c & crsh_c_ty_pri_v(crsh_c_ty(cz_c_n)),
c & mx_c_pri_fn_v
c write(crsh_ou_cn, 9060)cz_r_n,
c & crsh_r_n_act_en(cz_r_n),
c & ch3_crsh_vr_ty(crsh_r_ty(cz_r_n)),
c & crsh_r_ty_pri_v(crsh_r_ty(cz_r_n)),
c & mx_r_pri_fn_v,
c & cz_c_n,
c & crsh_c_n_act_en(cz_c_n),
c & ch3_crsh_vr_ty(crsh_c_ty(cz_c_n)),
c & crsh_c_ty_pri_v(crsh_c_ty(cz_c_n)),
c & mx_c_pri_fn_v
c call ems_flush(crsh_ou_cn)
c
c Make the chosen logical nonbasic and the chosen structural basic.
c
n_crsh_bs_cg = n_crsh_bs_cg + 1
crsh_vr_ty = crsh_r_ty(cz_r_n)
crsh_vr_ty_rm_n_r(crsh_vr_ty) =
& crsh_vr_ty_rm_n_r(crsh_vr_ty) + 1
crsh_vr_ty = crsh_c_ty(cz_c_n)
crsh_vr_ty_add_n_c(crsh_vr_ty) =
& crsh_vr_ty_add_n_c(crsh_vr_ty) + 1
st(cz_c_n) = st(cz_c_n) + bc_bt
lg_vr_n = mx_n_c + cz_r_n
st(lg_vr_n) = st(lg_vr_n) - bc_bt
c
c Update the row and column counts
c
do 140, r_el_n = crsh_mtx_r_sa(cz_r_n), crsh_mtx_r_sa(cz_r_n+1)-1
c_n = crsh_mtx_c_ix(r_el_n)
if (crsh_c_st(c_n) .eq. crsh_vr_st_no_act) go to 140
do 130, el_n = mtx_c_sa(c_n), mtx_c_sa(c_n+1)-1
r_n = mtx_r_ix(el_n)
c if (crsh_r_st(r_n) .eq. crsh_vr_st_no_act) go to 130
crsh_r_n_act_en(r_n) = crsh_r_n_act_en(r_n) - 1
if (crsh_r_n_act_en(r_n) .eq. 0)
& crsh_r_st(r_n) = crsh_vr_st_no_act
130 continue
crsh_c_st(c_n) = crsh_vr_st_no_act
140 continue
if (crsh_r_st(cz_r_n) .ne. crsh_vr_st_no_act) goto 8010
if (crsh_c_st(cz_c_n) .ne. crsh_vr_st_no_act) goto 8020
go to 100
1000 continue
CM IF (emsol_dev .EQ. 1) THEN
C? if (n_crsh_bs_cg .eq. 0) then
C? write(crsh_ou_cn, 9200)
C? else
C? write(crsh_ou_cn, 9210)n_crsh_bs_cg
C? do 1010, crsh_vr_ty = crsh_f_vr_ty, crsh_l_vr_ty
C? if (crsh_vr_ty_og_n_r(crsh_vr_ty) .gt. 0) then
C? pct = ems_i_t_i_pct(crsh_vr_ty_rm_n_r(crsh_vr_ty),
C? & crsh_vr_ty_og_n_r(crsh_vr_ty))
C? write(crsh_ou_cn, 9220)' Removed ',
C? & crsh_vr_ty_rm_n_r(crsh_vr_ty),
C? & crsh_vr_ty_og_n_r(crsh_vr_ty),
C? & pct, 'rows ', ch3_crsh_vr_ty(crsh_vr_ty)
C? end if
C? 1010 continue
C? do 1020, crsh_vr_ty = crsh_f_vr_ty, crsh_l_vr_ty
C? if (crsh_vr_ty_og_n_c(crsh_vr_ty) .gt. 0) then
C? pct = ems_i_t_i_pct(crsh_vr_ty_add_n_c(crsh_vr_ty),
C? & crsh_vr_ty_og_n_c(crsh_vr_ty))
C? write(crsh_ou_cn, 9220)' Added ',
C? & crsh_vr_ty_add_n_c(crsh_vr_ty),
C? & crsh_vr_ty_og_n_c(crsh_vr_ty),
C? & pct, 'columns', ch3_crsh_vr_ty(crsh_vr_ty)
C? end if
C? 1020 continue
C? write(crsh_ou_cn, 9230)
C? call ems_rp_crsh_vr_ty(
C? & crsh_ou_cn, st, crsh_r_ty, crsh_c_ty)
C? end if
C? call ems_flush(crsh_ou_cn)
CM ENDIF
c
c Get lists of basic and nonbasic variables from the status
c
n_vr_in_r = 0
n_vr_in_c = 0
do 1110, vr_n = 1, n_c
if (iand(st(vr_n), bc_bt) .ne. 0) then
n_vr_in_r = n_vr_in_r + 1
vr_in_r(n_vr_in_r) = vr_n
else
n_vr_in_c = n_vr_in_c + 1
vr_in_c(n_vr_in_c) = vr_n
endif
1110 continue
do 1120, vr_n = mx_n_c+1, mx_n_c+n_r
if (iand(st(vr_n), bc_bt) .ne. 0) then
n_vr_in_r = n_vr_in_r + 1
vr_in_r(n_vr_in_r) = vr_n
else
n_vr_in_c = n_vr_in_c + 1
vr_in_c(n_vr_in_c) = vr_n
endif
1120 continue
if (n_vr_in_r .ne. n_r) goto 8030
if (n_vr_in_c .ne. n_c) goto 8040
7000 continue
CM IF (emsol_dev .EQ. 1) THEN
C? call ems_flush(crsh_ou_cn)
CM ENDIF
c
c Indicate that the condition of the basis may be questionable.
c
ml_da_st_msk =
& ml_da_st_msk - iand(ml_da_st_msk, ml_da_st_bs_cond_ok)
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
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)
& crsh_r_st(cz_r_n)
call ems_msg_wr_li(bug_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)
& crsh_c_st(cz_c_n)
call ems_msg_wr_li(bug_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)
call ems_msg_wr_li(bug_msg_n)
goto 7000
8040 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9804)
call ems_msg_wr_li(bug_msg_n)
goto 7000
CM IF (emsol_dev .EQ. 1) THEN
C? 9000 format(//'LTSF Crash')
C? 9010 format(//'Before crash:')
CM ENDIF
c 9050 format(
c & ' Row Count Ty Pri Fn_v | ',
c & ' Col Count Ty Pri Fn_v')
c 9060 format(
c & i7, 2x, i4, 2x, a3, 2x, i3, 2x, i5, ' | ',
c & i7, 2x, i4, 2x, a3, 2x, i3, 2x, i5)
c 9100 format(' Row Count Ty Pri Fn_v Cz_r Mx_Fn_v')
c 9110 format(i7, 2x, i4, 2x, a3, 2x, i3, 2x, i5, 3x, i7, 4x, i5)
c 9120 format(' Col Count Ty Pri Fn_v Cz_c Mx_Fn_v')
CM IF (emsol_dev .EQ. 1) THEN
C? 9200 format(//'Crash made no basis changes')
C? 9210 format(//'LTSF Crash made ', i7, ' basis changes')
C? 9220 format(a9, i7, ' of ', i7,
C? & ' (', i3, '%) ', a7, ' of type ', a3)
C? 9230 format(//'After crash:')
CM ENDIF
9800 format('STRANGE: cz_c_n = 0')
9801 format('STRANGE: crsh_r_st(cz_r_n) = ', i7)
9802 format('STRANGE: crsh_c_st(cz_c_n) = ', i7)
9803 format('CRASH: n_vr_in_r .ne. n_r')
9804 format('CRASH: n_vr_in_c .ne. n_c')
end
C->>> -------------------------------------> ems_iz_ltssf_crsh_vr_ty <<<
c Initialise row and column types according to crash type
c
subroutine ems_iz_ltssf_crsh_vr_ty(crsh_ty,
& lbc,
& ubc,
& st,
& crsh_r_ty,
& crsh_c_ty)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'EMSPM.INC'
include 'ICTVR.INC'
include 'CRASH.INC'
integer crsh_ty
double precision lbc(0:mx_n_c+n_r)
double precision ubc(0:mx_n_c+n_r)
integer st(0:mx_n_c+n_r)
integer crsh_r_ty(0:n_r)
integer crsh_c_ty(0:n_c)
integer r_n, c_n, vr_n, crsh_vr_ty
if (crsh_ty .eq. 0) then
do 10, r_n = 1, n_r
vr_n = mx_n_c + r_n
if (iand(st(vr_n), bc_bt) .ne. 0) then
crsh_vr_ty = crsh_vr_ty_bc
else
crsh_vr_ty = crsh_vr_ty_non_bc
endif
crsh_r_ty(r_n) = crsh_vr_ty
10 continue
do 20, c_n = 1, n_c
vr_n = c_n
if (iand(st(vr_n), bc_bt) .ne. 0) then
crsh_vr_ty = crsh_vr_ty_bc
else
crsh_vr_ty = crsh_vr_ty_non_bc
endif
crsh_c_ty(c_n) = crsh_vr_ty
20 continue
else
do 110, r_n = 1, n_r
vr_n = mx_n_c + r_n
if (ubc(vr_n) .ge. inf) then
if (lbc(vr_n) .le. -inf) then
c FR:
crsh_vr_ty = crsh_vr_ty_fr
else
c LB:
crsh_vr_ty = crsh_vr_ty_1_sd
end if
else
if (lbc(vr_n) .le. -inf) then
c UB:
crsh_vr_ty = crsh_vr_ty_1_sd
else
if (lbc(vr_n) .lt. ubc(vr_n)) then
c LB/UB:
crsh_vr_ty = crsh_vr_ty_2_sd
else
c FX:
crsh_vr_ty = crsh_vr_ty_fx
end if
end if
end if
crsh_r_ty(r_n) = crsh_vr_ty
110 continue
do 120, c_n = 1, n_c
vr_n = c_n
if (ubc(vr_n) .ge. inf) then
if (lbc(vr_n) .le. -inf) then
c FR:
crsh_vr_ty = crsh_vr_ty_fr
else
c LB:
crsh_vr_ty = crsh_vr_ty_1_sd
end if
else
if (lbc(vr_n) .le. -inf) then
c UB:
crsh_vr_ty = crsh_vr_ty_1_sd
else
if (lbc(vr_n) .ne. ubc(vr_n)) then
c LB/UB:
crsh_vr_ty = crsh_vr_ty_2_sd
else
c FX:
crsh_vr_ty = crsh_vr_ty_fx
end if
end if
end if
crsh_c_ty(c_n) = crsh_vr_ty
120 continue
endif
return
end
C->>> ---------------------------------------------> ems_iz_crsh_com <<<
subroutine ems_iz_crsh_com(crsh_ty)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'CRASH.INC'
integer crsh_ty
integer crsh_vr_ty
crsh_ou_cn = 6
c
c Initialise the array entries so that something is assigned for all
c of them
c
c do crsh_vr_ty = crsh_f_vr_ty, crsh_l_vr_ty
if (crsh_ty .eq. 0) then
c
c Basis-preserving LTSSF crash
c
ch3_crsh_vr_ty(crsh_vr_ty_bc) = ' Bc'
ch3_crsh_vr_ty(crsh_vr_ty_non_bc) = 'NBc'
crsh_r_ty_pri_v(crsh_vr_ty_non_bc) = 6
crsh_r_ty_pri_v(crsh_vr_ty_bc) = 0
crsh_c_ty_pri_v(crsh_vr_ty_non_bc) = 0
crsh_c_ty_pri_v(crsh_vr_ty_bc) = 6
else if (crsh_ty .eq. 1) then
c
c Standard LTSSF crash
c
ch3_crsh_vr_ty(crsh_vr_ty_fx) = ' Fx'
ch3_crsh_vr_ty(crsh_vr_ty_2_sd) = ' 2s'
ch3_crsh_vr_ty(crsh_vr_ty_1_sd) = ' 1s'
ch3_crsh_vr_ty(crsh_vr_ty_fr) = ' Fr'
crsh_r_ty_pri_v(crsh_vr_ty_fx) = 6
crsh_r_ty_pri_v(crsh_vr_ty_2_sd) = 4
crsh_r_ty_pri_v(crsh_vr_ty_1_sd) = 2
crsh_r_ty_pri_v(crsh_vr_ty_fr) = 0
crsh_c_ty_pri_v(crsh_vr_ty_fx) = 0
crsh_c_ty_pri_v(crsh_vr_ty_2_sd) = 2
crsh_c_ty_pri_v(crsh_vr_ty_1_sd) = 4
crsh_c_ty_pri_v(crsh_vr_ty_fr) = 6
else if (crsh_ty .eq. 2) then
c
c LTSF crash
c
ch3_crsh_vr_ty(crsh_vr_ty_fx) = ' Fx'
ch3_crsh_vr_ty(crsh_vr_ty_fx_ze_fs) = '0Fx'
ch3_crsh_vr_ty(crsh_vr_ty_2_sd) = ' 2s'
ch3_crsh_vr_ty(crsh_vr_ty_2_sd_ze_fs) = '02s'
ch3_crsh_vr_ty(crsh_vr_ty_1_sd) = ' 1s'
ch3_crsh_vr_ty(crsh_vr_ty_1_sd_ze_fs) = '01s'
ch3_crsh_vr_ty(crsh_vr_ty_fr) = ' Fr'
crsh_r_ty_pri_v(crsh_vr_ty_fx) = 6
crsh_r_ty_pri_v(crsh_vr_ty_fx_ze_fs) = 6
crsh_r_ty_pri_v(crsh_vr_ty_2_sd) = 4
crsh_r_ty_pri_v(crsh_vr_ty_2_sd_ze_fs) = 4
crsh_r_ty_pri_v(crsh_vr_ty_1_sd) = 2
crsh_r_ty_pri_v(crsh_vr_ty_1_sd_ze_fs) = 2
crsh_r_ty_pri_v(crsh_vr_ty_fr) = 0
crsh_c_ty_pri_v(crsh_vr_ty_fx) = 0
crsh_c_ty_pri_v(crsh_vr_ty_fx_ze_fs) = 0
crsh_c_ty_pri_v(crsh_vr_ty_2_sd) = 2
crsh_c_ty_pri_v(crsh_vr_ty_2_sd_ze_fs) = 2
crsh_c_ty_pri_v(crsh_vr_ty_1_sd) = 4
crsh_c_ty_pri_v(crsh_vr_ty_1_sd_ze_fs) = 4
crsh_c_ty_pri_v(crsh_vr_ty_fr) = 6
endif
c
c Cross-check that the priority values are within the range of
c header indices
c
do crsh_vr_ty = crsh_f_vr_ty, crsh_l_vr_ty
if (
& crsh_c_ty_pri_v(crsh_vr_ty) .lt. crsh_mn_pri_v .or.
& crsh_c_ty_pri_v(crsh_vr_ty) .gt. crsh_mx_pri_v) then
c write(*, *)'Crash column type ', crsh_vr_ty,
c & '(', ch3_crsh_vr_ty(crsh_vr_ty), ')',
c & ' has priority value ', crsh_c_ty_pri_v(crsh_vr_ty),
c & ' which is not in valid range from ',
c & crsh_mn_pri_v, ' to ', crsh_mx_pri_v
end if
if (
& crsh_r_ty_pri_v(crsh_vr_ty) .lt. crsh_mn_pri_v .or.
& crsh_r_ty_pri_v(crsh_vr_ty) .gt. crsh_mx_pri_v) then
c write(*, *)'Crash row type ', crsh_vr_ty,
c & '(', ch3_crsh_vr_ty(crsh_vr_ty), ')',
c & ' has priority value ', crsh_r_ty_pri_v(crsh_vr_ty),
c & ' which is not in valid range from ',
c & crsh_mn_pri_v, ' to ', crsh_mx_pri_v
end if
end do
return
end
C->>> ----------------------------------------------> ems_ltssf_crsh <<<
c Perform LTSSF crash.
c
subroutine ems_ltssf_crsh(
& lbc,
& ubc,
& st,
& pr_act,
& vr_in_r,
& vr_in_c,
& mtx_r_v,
& mtx_r_ix,
& mtx_c_sa,
& crsh_r_ty,
& crsh_r_pri_lkb,
& crsh_r_pri_lkf,
& crsh_c_ty,
& crsh_r_n_act_en,
& crsh_r_n_act_en_hdr,
& crsh_r_n_act_en_lkb,
& crsh_r_n_act_en_lkf,
& crsh_c_n_act_en,
& crsh_mtx_c_mx_abs_v,
& crsh_mtx_c_v,
& crsh_mtx_c_ix,
& crsh_mtx_r_sa,
& crsh_r_st,
& crsh_c_st,
& pv_r_ls,
& pv_a_el,
& rhs, sol)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'EMSPM.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'CRASH.INC'
include 'EMSMSG.INC'
double precision lbc(0:mx_n_c+n_r)
double precision ubc(0:mx_n_c+n_r)
integer st(0:mx_n_c+n_r)
double precision pr_act(0:mx_n_c+n_r)
integer vr_in_r(0:n_r)
integer vr_in_c(0:n_c)
double precision mtx_r_v(0:n_a_el)
integer mtx_r_ix(0:n_a_el)
integer mtx_c_sa(0:n_c+1)
integer crsh_r_ty(0:n_r)
integer crsh_r_pri_lkb(0:n_r)
integer crsh_r_pri_lkf(0:n_r)
integer crsh_c_ty(0:n_c)
integer crsh_r_n_act_en(0:n_r)
integer crsh_r_n_act_en_hdr(0:n_c)
integer crsh_r_n_act_en_lkb(0:n_r)
integer crsh_r_n_act_en_lkf(0:n_r)
integer crsh_c_n_act_en(0:n_c)
double precision crsh_mtx_c_mx_abs_v(0:n_c)
double precision crsh_mtx_c_v(0:n_a_el)
integer crsh_mtx_c_ix(0:n_a_el)
integer crsh_mtx_r_sa(0:n_r+1)
integer crsh_r_st(0:n_r)
integer crsh_c_st(0:n_c)
integer pv_r_ls(0:n_r)
integer pv_a_el(0:n_r)
double precision rhs(0:n_r)
double precision sol(0:n_r)
integer r_n, c_n, vr_n, el_n, r_el_n, lg_vr_n, struc_vr_n
integer cz_r_n, r_pri_fn_v, mx_r_pri_fn_v, lm_r_pri_fn_v
integer cz_c_n, c_pri_fn_v, mx_c_pri_fn_v
c integer ck_lvl
integer crsh_it_n, n_crsh_bs_cg
integer crsh_vr_ty
integer crsh_pri_v, r_pri_v
integer crsh_n_act_en, r_n_act_en
integer mx_r_pri_v
integer prev_r_n, nx_r_n
integer n_vr_in_r, n_vr_in_c
integer crsh_ps_mod_2
double precision pv_v
double precision abs_c_v, abs_pv_v
double precision rlv_pv_v
double precision mn_abs_pv_v
double precision mn_rlv_pv_v
double precision nw_tl_crsh_abs_pv_v
double precision nw_tl_crsh_rlv_pv_v
double precision ftran_rsdu_norm, btran_rsdu_norm
integer n_abs_pv_no_ok
integer n_rlv_pv_no_ok
logical abs_pv_v_ok, rlv_pv_v_ok, pv_ok
CM IF (emsol_dev .EQ. 1) THEN
C? integer ems_i_t_i_pct
C? integer pct
C? logical cz_r_rp_lvl_2_li
CM ENDIF
c logical er_fd
integer crsh_fn_cf_pri_v
integer crsh_fn_cf_n_act_en
parameter (
& crsh_fn_cf_pri_v = 1,
& crsh_fn_cf_n_act_en = 10)
n_crsh_ps = 1
10 continue
call ems_ltssf_iz_da_str(
& lbc, ubc, st,
& mtx_r_v, mtx_r_ix, mtx_c_sa,
& crsh_r_ty, crsh_r_pri_lkb, crsh_r_pri_lkf,
& crsh_c_ty,
& crsh_r_n_act_en, crsh_r_n_act_en_hdr,
& crsh_r_n_act_en_lkb, crsh_r_n_act_en_lkf,
& crsh_c_n_act_en,
& crsh_mtx_c_mx_abs_v,
& crsh_mtx_c_v, crsh_mtx_c_ix, crsh_mtx_r_sa,
& crsh_r_st, crsh_c_st)
CM IF (emsol_dev .EQ. 1) THEN
C? write(crsh_ou_cn, 9000)n_crsh_ps,
C? & tl_crsh_abs_pv_v, tl_crsh_rlv_pv_v
C? if (n_crsh_ps .eq. 1) then
C? write(crsh_ou_cn, 9010)
C? call ems_rp_crsh_vr_ty(
C? & crsh_ou_cn, st, crsh_r_ty, crsh_c_ty)
C? cz_r_rp_lvl_2_li = .false.
C? call ems_flush(crsh_ou_cn)
C? endif
CM ENDIF
crsh_it_n = 0
n_crsh_bs_cg = 0
n_vr_in_r = 0
mn_abs_pv_v = inf
mn_rlv_pv_v = inf
n_abs_pv_no_ok = 0
n_rlv_pv_no_ok = 0
c
c Get the maximum row priority value
c
mx_r_pri_v = -i_inf
do crsh_pri_v = crsh_mn_pri_v, crsh_mx_pri_v
if (crsh_r_pri_v_hdr(crsh_pri_v) .gt. 0)
& mx_r_pri_v = crsh_pri_v
end do
if (mx_r_pri_v .eq. -i_inf) go to 1000
100 continue
CM IF (emsol_dev .EQ. 1) THEN
C? if (mod(crsh_it_n, 1000) .eq. 0) then
C? ck_lvl = 1
C? call ems_ltssf_ck_da_str(er_fd, ck_lvl,
C? & st,
C? & mtx_r_v, mtx_r_ix, mtx_c_sa,
C? & crsh_r_ty, crsh_r_pri_lkb, crsh_r_pri_lkf,
C? & crsh_c_ty,
C? & crsh_r_n_act_en, crsh_r_n_act_en_hdr,
C? & crsh_r_n_act_en_lkb, crsh_r_n_act_en_lkf,
C? & crsh_c_n_act_en,
C? & crsh_mtx_c_mx_abs_v,
C? & crsh_mtx_c_v, crsh_mtx_c_ix, crsh_mtx_r_sa,
C? & crsh_r_st, crsh_c_st)
C? if (er_fd) go to 1000
C? end if
C? call ems_rp_crsh_act_mtx(crsh_ou_cn,
C? & crsh_r_n_act_en,
C? & crsh_c_n_act_en,
C? & crsh_r_ty,
C? & crsh_c_ty,
C? & crsh_r_st,
C? & crsh_c_st,
C? & crsh_mtx_c_ix, crsh_mtx_r_sa,
C? & mtx_r_ix, mtx_c_sa)
CM ENDIF
crsh_it_n = crsh_it_n + 1
c
c Choose a row with maximium priority function
c
c cz_r_n = 0
c mx_r_pri_fn_v = -i_inf
c
c According to the relative size of crsh_fn_cf_pri_v and
c crsh_fn_cf_n_act_en, search over decreasing row priority or
c increasing row count
c
c do 101, r_n = 1, n_r
c if (crsh_r_st(r_n) .eq. crsh_vr_st_no_act) go to 101
c crsh_pri_v = crsh_r_ty_pri_v(crsh_r_ty(r_n))
c crsh_n_act_en = crsh_r_n_act_en(r_n)
c r_pri_fn_v =
c & crsh_fn_cf_pri_v*crsh_pri_v -
c & crsh_fn_cf_n_act_en*crsh_n_act_en
c if (r_pri_fn_v .gt. mx_r_pri_fn_v) then
c cz_r_n = r_n
c mx_r_pri_fn_v = r_pri_fn_v
c end if
c 101 continue
c sv_cz_r_n = cz_r_n
c sv_mx_r_pri_fn_v = mx_r_pri_fn_v
c
c Choose a row with maximium priority function
c
cz_r_n = 0
mx_r_pri_fn_v = -i_inf