-
Notifications
You must be signed in to change notification settings - Fork 2
/
sed_r_d.f
3531 lines (3525 loc) · 118 KB
/
sed_r_d.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 IF (dan .EQ. 1) THEN
C?C->>> ----------------------------------------------> ems_dan_cz_r <<<
C?c
CM IF (sps_cz_r .EQ. 1) THEN
C? subroutine ems_dan_sps_cz_r(
CM ELSE
C? subroutine ems_dan_cz_r(
CM ENDIF
C? & rp_growth, refined_pv_c, refine_pv_c,
CM ENDIF
CM IF (dvx .EQ. 1) THEN
C?C->>> ----------------------------------------------> ems_dvx_cz_r <<<
C?c
CM IF (sps_cz_r .EQ. 1) THEN
C? subroutine ems_dvx_sps_cz_r(
CM ELSE
C? subroutine ems_dvx_cz_r(
CM ENDIF
C? & rp_growth, refined_pv_c, refine_pv_c,
C? & ed_wt,
C? & dvx_ix,
CM ENDIF
CM IF (sed .EQ. 1) THEN
C->>> ----------------------------------------------> ems_sed_cz_r <<<
c
CM IF (sps_cz_r .EQ. 1) THEN
C? subroutine ems_sed_sps_cz_r(
CM ELSE
subroutine ems_sed_cz_r(
CM ENDIF
& rp_growth, refined_pv_c, refine_pv_c,
& mx_ed_wt_er,
& ed_wt,
CM ENDIF
& rsmi_lb, rsmi_ub, pr_act, st, vr_in_r,
& nw_eta_v, pv_c_v, nw_eta_ix,
& cdd_ix,
& 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 'MORSMI.INC'
CM IF (emsol_da .EQ. 1) THEN
C? include 'EMSDA.INC'
CM ENDIF
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
CM IF (emsol_tt .EQ. 1) THEN
C? include 'EMSTT.INC'
CM ENDIF
integer rd_en_vr_n, rd_lv_vr_n
common/ems_rd_lv_vr_n_com/rd_en_vr_n, rd_lv_vr_n
logical rp_growth, refined_pv_c, refine_pv_c
integer st(0:mx_n_c+n_r)
integer vr_in_r(0:n_r), nw_eta_ix(0:n_r)
integer cdd_ix(0:1+n_r), is(0:is_n_en_m1)
CM IF (dvx .EQ. 1) THEN
C? integer dvx_ix(0:mx_n_c+n_r)
C? double precision ed_wt(0:mx_n_c+n_r)
CM ENDIF
CM IF (sed .EQ. 1) THEN
double precision mx_ed_wt_er
double precision ed_wt(0:mx_n_c+n_r)
CM ENDIF
double precision rsmi_lb(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)
double precision nw_eta_v(0:n_r), pv_c_v(0:n_r)
double precision ds(0:ds_n_en_m1)
c
integer r_n, vr_n, vr_st
integer ix_n, ix_o_f_fs_vr_t_bd, ix_o_l_ifs_vr_t_bd
integer ix_o_vr_t_lv_bs, loop_n, n_rpt, rpt
integer n_cdd_ix, n_cdd_ix0, cdd_ix_n
integer cdd_ix_n_o_l_ifs_vr_t_bd, cdd_ix_n_o_f_fs_vr_t_bd
integer n_ifs_cdd_r, n_ifs_r
integer growth_mode
integer n_mv_bd, n_cg_act
CM IF (sps_cz_r .EQ. 1) THEN
C? integer og_ix_n, og_n_ix
CM ENDIF
logical r_n_in_cdd_ls
logical ck_cdd_ls
logical al_cdd_ifs
logical rpt_cz_r
integer prev_n_ix
CM IF (dvx .EQ. 1) THEN
C? integer i_te
C? double precision dvx_rao
CM ENDIF
CM IF (sed .EQ. 1) THEN
double precision ed_wt_er
CM ENDIF
double precision aa_1, aa_2
double precision rao_fs, rao_ifs
double precision aa_fs, aa_ifs
double precision psi
double precision ok_pv, mx_pv
double precision rsdu
double precision growth
double precision og_tl_pr_ifs
double precision mx_dl_bd, mx_dl_act
CM IF (sed .EQ. 1) THEN
double precision og_ed_wt_o_vr_t_en_bs
CM ENDIF
CM IF (dvx .EQ. 1) THEN
C? double precision og_ed_wt_o_vr_t_en_bs
CM ENDIF
CM IF (emsol_da .EQ. 1) THEN
C?c integer i
C?c double precision v
CM ENDIF
c double precision rl_null
c save rl_null
c data rl_null/0d0/
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl0) call ems_tt_rec(cz_r_tt, n_bs)
CM ENDIF
prev_n_ix = i_inf
100 continue
CM IF (dvx .EQ. 1) THEN
C? og_ed_wt_o_vr_t_en_bs = ed_wt(vr_t_en_bs)
C? ed_wt_o_vr_t_en_bs = zero
CM ENDIF
CM IF (sed .EQ. 1) THEN
og_ed_wt_o_vr_t_en_bs = ed_wt(vr_t_en_bs)
ed_wt_o_vr_t_en_bs = zero
CM ENDIF
mx_pv_c_v = zero
mx_pv = one
alg_er = .false.
un_bd = .false.
refine_pv_c = .false.
r_n_in_cdd_ls = .false.
ck_cdd_ls = .false.
al_cdd_ifs = .true.
c
c Set ix_n = -1, vr_in_r(0) = vr_t_en_bs and pv_c_v(0) = 1 so that
c this value is packed into nw_eta_v(0) with index nw_eta_ix(0) =
c vr_t_en_bs. Thus, ratios for bound swaps can be determined in the
c same loop as the other ratios.
c
ix_n = -1
vr_in_r(0) = vr_t_en_bs
c NO_SGN pv_c_v(0) = one
c SGN pv_c_v(0) = mv_dir*one
CM IF (sps_cz_r .EQ. 1) THEN
C? og_n_ix = nw_eta_ix(0)
C? nw_eta_ix(0) = 0
CM ENDIF
pv_c_v(0) = one
nw_eta_f_ix = 1
if (lp_ph .eq. 1) goto 500
c=======================================================================
c Start of phase II cz_r
c
c Ratio test with expanded bounds.
c
c=======================================================================
c
tl_pr_ifs = tl_pr_ifs + xp_tau
n_rpt = 0
200 continue
n_cdd_ix = 0
rsdu = inf
og_tl_pr_ifs = tl_pr_ifs
aa_1 = inf
ix_o_vr_t_lv_bs = -1
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1)
CM IF (sps_cz_r .EQ. 1) THEN
C? & call ems_tt_rec(cz_r_ph_2_sps_ps_1_tt, n_bs)
CM ELSE
C? & call ems_tt_rec(cz_r_ph_2_dse_ps_1_tt, n_bs)
CM ENDIF
CM ENDIF
c call ems_rp_cz_r(lp_ph, -1,
c & 0, rl_null, rl_null, rl_null, rl_null)
CM IF (sps_cz_r .EQ. 1) THEN
C? do 210, og_ix_n = 0, og_n_ix
C? r_n = nw_eta_ix(og_ix_n)
CM ELSE
do 210, r_n = 0, n_r
CM ENDIF
pv = pv_c_v(r_n)
CM IF (emsol_da .EQ. 1) THEN
C?c if (pv .ne. zero) then
C?c v = abs(pv)
C?c if (v .le. 1d0) v = v*1d-1
C?c i = log10(v)
C?c if (i .lt. mn_pv_c_v_rec_by_1)
C?c & i = mn_pv_c_v_rec_by_1-1 - (mn_pv_c_v_rec_by_1-i)/10
C?c i = max(min(i, mx_pv_c_v_rec_by_1), mn_pv_c_v_rec_by_10)
C?c pv_c_v_rec(i) = pv_c_v_rec(i) + 1
C?c su_n_pk_pv_c_en = su_n_pk_pv_c_en + 1
C?c if (abs(pv) .le. pk_pv_c_ze)
C?c & su_n_pk_pv_c_ze = su_n_pk_pv_c_ze + 1
C?c end if
CM ENDIF
if (pv .eq. zero) goto 210
CM IF (dan .EQ. 1) THEN
C? pv_c_v(r_n) = zero
CM ENDIF
CM IF (dvx .EQ. 1) THEN
C? pv_c_v(r_n) = zero
CM ENDIF
if (abs(pv) .le. pk_pv_c_ze) then
pv_c_v(r_n) = zero
goto 210
end if
ix_n = ix_n + 1
mx_pv_c_v = max(abs(pv), mx_pv_c_v)
nw_eta_v(ix_n) = pv
nw_eta_ix(ix_n) = r_n
vr_n = vr_in_r(r_n)
CM IF (dvx .EQ. 1) THEN
C? if (dvx_ix(vr_n) .gt. 0)
C? & ed_wt_o_vr_t_en_bs = ed_wt_o_vr_t_en_bs + pv*pv
CM ENDIF
CM IF (sed .EQ. 1) THEN
ed_wt_o_vr_t_en_bs = ed_wt_o_vr_t_en_bs + pv*pv
CM ENDIF
c
c Now complete the CHUZR pass 1 loop.
c
c NO_SGN pv = mv_dir*pv
pv = mv_dir*pv
vr_st = st(vr_n)
c call ems_rp_cz_r(lp_ph, r_n, vr_st,
c & pv, rsmi_lb(vr_n), pr_act(vr_n), rsmi_ub(vr_n))
if (pv .gt. zero) then
if (iand(vr_st, ub_bt) .ne. 0) then
c
c The variable is moving towards an upper bound or breakpoint.
c
rsdu = rsmi_ub(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .lt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .le. aa_1*pv) then
c
c The standard ratio is less than the current smallest ratio with
c respect to expanded bounds.
c
c * it may be a candidate in the pass 2 ratio test.
c
c If it corresponds to a bound rather than just a breakpoint then
c
c * it may give a ratio with respect to the expanded bound which
c is smaller than the current smallest;
c
c NB It the variable is BP then there is no need to consider this.
c
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
rsdu = rsdu + tl_pr_ifs
if (rsdu .lt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
end if
else
goto 210
end if
else
if (iand(vr_st, lb_bt) .ne. 0) then
c
c The variable is moving towards a lower bound or breakpoint.
c
c NB the residual rsmi_lb(vr_n)-pr_act(vr_n) and the pivot are both
c negative so reverse the sign of the inequality.
c
rsdu = rsmi_lb(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .gt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .ge. aa_1*pv) then
c
c The standard ratio is less than the current smallest ratio with
c respect to expanded bounds.
c
c * it may be a candidate in the pass 2 ratio test.
c
c If it corresponds to a bound rather than just a breakpoint then
c
c * it may give a ratio with respect to the expanded bound which
c is smaller than the current smallest;
c
c NB It the variable is BP then there is no need to consider this.
c
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
rsdu = rsdu - tl_pr_ifs
if (rsdu .gt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
end if
else
goto 210
end if
end if
210 continue
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1)
CM IF (sps_cz_r .EQ. 1) THEN
C? & call ems_tt_rec(-cz_r_ph_2_sps_ps_1_tt, n_bs)
CM ELSE
C? & call ems_tt_rec(-cz_r_ph_2_dse_ps_1_tt, n_bs)
CM ENDIF
CM ENDIF
nw_eta_l_ix = ix_n
ok_pv = mx_pv_c_v/tl_cz_r_growth
if (ix_o_vr_t_lv_bs .lt. 0) then
loop_n = 210
goto 8040
end if
pv = nw_eta_v(ix_o_vr_t_lv_bs)
vr_t_lv_bs = vr_in_r(nw_eta_ix(ix_o_vr_t_lv_bs))
if (aa_1 .lt. zero) then
call ems_consider_rpt_rao_ts(
& rpt, n_rpt, pv, vr_t_lv_bs, aa_1,
& st, rsmi_lb, rsmi_ub, pr_act, ds, is)
if (rpt .eq. -5) then
goto 8050
else if (rpt .eq. -3) then
goto 8030
else
goto 200
end if
end if
c
c Alpha_1 should not be less than the minimum step due to primal
c feasibility tolerance.
c
if (pv .eq. zero) goto 8090
if (aa_1 .lt. xp_tau/abs(pv)) goto 8060
if (ix_o_vr_t_lv_bs .eq. 0) then
c
c If the first variable to become infeasible is the entering
c variable then the ratio test yields a bound swap. The step alpha_1
c swaps the activity to its expanded bound so set alpha to the step
c to the original bound (alpha < alpha_1).
c
vr_t_lv_bs = vr_in_r(0)
aa = inf
if (mv_dir .gt. 0) then
aa = rsmi_ub(vr_t_lv_bs) - pr_act(vr_t_lv_bs)
else
aa = pr_act(vr_t_lv_bs) - rsmi_lb(vr_t_lv_bs)
end if
c
c If alpha for a bound swap is less than the minimum step then this
c suggests something very odd. Any bound swap should be at least
c the current infeasibility tolerance which is greater than the
c minimum step.
c
if (aa .lt. xp_tau) goto 8070
c call ems_rp_cz_r(lp_ph, n_r+1, 0, aa_1, aa, rl_null, rl_null)
c call ems_rp_cz_r(lp_ph, n_r+2,
c & 0, aa, mx_pv_c_v, rl_null, rl_null)
goto 1000
end if
c
c End of first pass for phase II.
c=======================================================================
c Start of second pass for phase II.
c
aa_2 = inf
mx_pv = zero
ix_o_vr_t_lv_bs = 0
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1) call ems_tt_rec(cz_r_ph_2_ps_2_tt, n_bs)
CM ENDIF
do 310, cdd_ix_n = 1, n_cdd_ix
c
c Note that all candidates have a pivot which is sufficiently large
c and a finite value to move to which is given by the signed pivot.
c
ix_n = cdd_ix(cdd_ix_n)
pv = nw_eta_v(ix_n)
c NO_SGN pv = mv_dir*pv
pv = mv_dir*pv
vr_n = vr_in_r(nw_eta_ix(ix_n))
c Not used! vr_st = st(vr_n)
if (pv .gt. zero) then
rsdu = rsmi_ub(vr_n) - pr_act(vr_n)
if (rsdu .le. aa_1*pv) then
if (pv .gt. mx_pv) then
aa_2 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
mx_pv = pv
end if
end if
else
rsdu = rsmi_lb(vr_n) - pr_act(vr_n)
if (rsdu .ge. aa_1*pv) then
if (-pv .gt. mx_pv) then
aa_2 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
mx_pv = -pv
end if
end if
end if
310 continue
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1) call ems_tt_rec(-cz_r_ph_2_ps_2_tt, n_bs)
CM ENDIF
if (ix_o_vr_t_lv_bs .lt. 0) then
loop_n = 310
goto 8040
end if
aa = aa_2
pv = nw_eta_v(ix_o_vr_t_lv_bs)
if (ix_o_vr_t_lv_bs .gt. 0 .and. abs(pv) .lt. ok_pv) then
c
c Growth will occur if this pivot is used: possibly refine the
c pivotal column.
c
if (iand(cz_r_msk, cz_r_refine_bt) .ne. 0 .and.
& .not. refined_pv_c) then
c
c Set up the values required to monitor growth.
c
pv_r_n = nw_eta_ix(ix_o_vr_t_lv_bs)
vr_n = vr_in_r(pv_r_n)
growth = abs(mx_pv_c_v/pv)
CM IF (emsol_dev .EQ. 1) THEN
C? call ems_mo_rsmi_growth(n_si_it, growth_act_refine_pv_c,
C? & pv_r_n, vr_n, pv, aa, growth, zero, 0)
CM ENDIF
refine_pv_c = .true.
rp_growth = .true.
goto 7000
end if
end if
c call ems_rp_cz_r(lp_ph, n_r+1, 0, aa_1, aa_2, rl_null, rl_null)
c call ems_rp_cz_r(lp_ph, n_r+2,
c & 0, aa, mx_pv_c_v, rl_null, rl_null)
goto 1000
c
c End of second pass for phase II.
c=======================================================================
c
c End of phase II cz_r
c=======================================================================
c Start of phase I cz_r
500 continue
c
c Ratio test with expanded bounds.
c
c Determine ix_o_f_fs_vr_t_bd, the index of the first variable to
c become infeasible, and ix_o_l_ifs_vr_t_bd, the index of the last
c infeasible activity to reach its nearest bound.
c
c=======================================================================
c Start of first pass for phase I.
c
tl_pr_ifs = tl_pr_ifs + xp_tau
n_rpt = 0
600 continue
n_ifs_r = 0
n_cdd_ix = 0
rsdu = inf
og_tl_pr_ifs = tl_pr_ifs
c
c Psi is the maximum pivot for infeasible basic variables which move
c towards their nearest bound.
c
psi = zero
aa_1 = inf
ix_o_vr_t_lv_bs = -1
vr_st = st(vr_t_en_bs)
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1)
CM IF (sps_cz_r .EQ. 1) THEN
C? & call ems_tt_rec(cz_r_ph_1_sps_ps_1_tt, n_bs)
CM ELSE
C? & call ems_tt_rec(cz_r_ph_1_dse_ps_1_tt, n_bs)
CM ENDIF
CM ENDIF
c call ems_rp_cz_r(lp_ph, -1,
c & 0, rl_null, rl_null, rl_null, rl_null)
CM IF (sps_cz_r .EQ. 1) THEN
C? do 610, og_ix_n = 0, og_n_ix
C? r_n = nw_eta_ix(og_ix_n)
CM ELSE
do 610, r_n = 0, n_r
CM ENDIF
pv = pv_c_v(r_n)
CM IF (emsol_da .EQ. 1) THEN
C?c if (pv .ne. zero) then
C?c v = abs(pv)
C?c if (v .le. 1d0) v = v*1d-1
C?c i = log10(v)
C?c if (i .lt. mn_pv_c_v_rec_by_1)
C?c & i = mn_pv_c_v_rec_by_1-1 - (mn_pv_c_v_rec_by_1-i)/10
C?c i = max(min(i, mx_pv_c_v_rec_by_1), mn_pv_c_v_rec_by_10)
C?c pv_c_v_rec(i) = pv_c_v_rec(i) + 1
C?c su_n_pk_pv_c_en = su_n_pk_pv_c_en + 1
C?c if (abs(pv) .le. pk_pv_c_ze)
C?c & su_n_pk_pv_c_ze = su_n_pk_pv_c_ze + 1
C?c end if
CM ENDIF
if (pv .eq. zero) goto 610
CM IF (dan .EQ. 1) THEN
C? pv_c_v(r_n) = zero
CM ENDIF
CM IF (dvx .EQ. 1) THEN
C? pv_c_v(r_n) = zero
CM ENDIF
if (abs(pv) .le. pk_pv_c_ze) then
pv_c_v(r_n) = zero
goto 610
end if
ix_n = ix_n + 1
mx_pv_c_v = max(abs(pv), mx_pv_c_v)
nw_eta_v(ix_n) = pv
nw_eta_ix(ix_n) = r_n
vr_n = vr_in_r(r_n)
CM IF (dvx .EQ. 1) THEN
C? if (dvx_ix(vr_n) .gt. 0)
C? & ed_wt_o_vr_t_en_bs = ed_wt_o_vr_t_en_bs + pv*pv
CM ENDIF
CM IF (sed .EQ. 1) THEN
ed_wt_o_vr_t_en_bs = ed_wt_o_vr_t_en_bs + pv*pv
CM ENDIF
c
c Now complete the CHUZR pass 1 loop.
c
c NO_SGN pv = mv_dir*pv
pv = mv_dir*pv
vr_st = st(vr_n)
c call ems_rp_cz_r(lp_ph, r_n, vr_st,
c & pv, rsmi_lb(vr_n), pr_act(vr_n), rsmi_ub(vr_n))
c
c Compare the residual with the scaled current smallest ratio to
c determine whether this row will be a candidate in pass 2.
c
if (iand(vr_st, ifs_bt) .ne. 0) then
if (pv .gt. zero) then
if (iand(vr_st, up_bt) .ne. 0) then
n_ifs_r = n_ifs_r + 1
psi = max(pv, psi)
rsdu = rsmi_lb(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .lt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .le. aa_1*pv) then
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
if (iand(vr_st, ub_bt) .ne. 0) then
rsdu = (rsmi_ub(vr_n) - pr_act(vr_n)) +
& tl_pr_ifs
if (rsdu .lt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
end if
end if
else
goto 610
end if
else
if (iand(vr_st, dn_bt) .ne. 0) then
n_ifs_r = n_ifs_r + 1
psi = max(-pv, psi)
rsdu = rsmi_ub(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .gt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .ge. aa_1*pv) then
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
if (iand(vr_st, lb_bt) .ne. 0) then
rsdu = (rsmi_lb(vr_n) - pr_act(vr_n)) -
& tl_pr_ifs
if (rsdu .gt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
end if
end if
else
goto 610
end if
end if
else
if (pv .gt. zero) then
if (iand(vr_st, ub_bt) .ne. 0) then
rsdu = rsmi_ub(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .lt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .le. aa_1*pv) then
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
rsdu = rsdu + tl_pr_ifs
if (rsdu .lt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
end if
else
goto 610
end if
else
if (iand(vr_st, lb_bt) .ne. 0) then
rsdu = rsmi_lb(vr_n) - pr_act(vr_n)
c Surely a mistake!! Changed 12/02/98
c if (rsdu .gt. aa_1*pv) then
c Surely a mistake!! Changed 12/02/98
if (rsdu .ge. aa_1*pv) then
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
rsdu = rsdu - tl_pr_ifs
if (rsdu .gt. aa_1*pv) then
aa_1 = rsdu/pv
ix_o_vr_t_lv_bs = ix_n
end if
else
goto 610
end if
else
goto 610
end if
end if
end if
610 continue
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1)
CM IF (sps_cz_r .EQ. 1) THEN
C? & call ems_tt_rec(-cz_r_ph_1_sps_ps_1_tt, n_bs)
CM ELSE
C? & call ems_tt_rec(-cz_r_ph_1_dse_ps_1_tt, n_bs)
CM ENDIF
CM ENDIF
nw_eta_l_ix = ix_n
ok_pv = mx_pv_c_v/tl_cz_r_growth
if (psi .eq. zero .and. ix_o_vr_t_lv_bs .lt. 0) then
c
c If there are no infeasible variables which reach a bound
c (indicated by psi remaining zero) and no variables which become
c infeasible then the problem is unbounded.
c
loop_n = 610
goto 8040
end if
if (ix_o_vr_t_lv_bs .lt. 0) then
vr_t_lv_bs = 0
else
vr_t_lv_bs = vr_in_r(nw_eta_ix(ix_o_vr_t_lv_bs))
pv = nw_eta_v(ix_o_vr_t_lv_bs)
end if
c
c If no variable can become infeasible goto pass two.
c
if (ix_o_vr_t_lv_bs .lt. 0) goto 700
if (aa_1 .lt. zero) then
call ems_consider_rpt_rao_ts(
& rpt, n_rpt, pv, vr_t_lv_bs, aa_1,
& st, rsmi_lb, rsmi_ub, pr_act, ds, is)
if (rpt .eq. -5) then
goto 8050
else if (rpt .eq. -3) then
goto 8030
else
goto 600
end if
end if
if (pv .eq. zero) goto 8090
if (aa_1 .lt. xp_tau/abs(pv)) goto 8060
if (psi .eq. zero .and. ix_o_vr_t_lv_bs .eq. 0) then
c
c If there are no infeasible variables which reach a bound
c (indicated by psi remaining zero) and the first variable to become
c infeasible is the entering variable then the ratio test yields a
c bound swap. The step alpha_1 swaps the activity to its expanded
c bound so set alpha to the step to the original bound. NB It is
c guaranteed that alpha<alpha_1.
c
vr_t_lv_bs = vr_in_r(0)
aa = inf
if (mv_dir .gt. 0) then
aa = rsmi_ub(vr_t_lv_bs) - pr_act(vr_t_lv_bs)
else
aa = pr_act(vr_t_lv_bs) - rsmi_lb(vr_t_lv_bs)
end if
if (aa .lt. xp_tau) goto 8070
n_cdd_ix = 0
c call ems_rp_cz_r(lp_ph, n_r+1, 0, aa_1, aa, -inf, rl_null)
c call ems_rp_cz_r(lp_ph, n_r+2,
c & 0, aa, mx_pv_c_v, rl_null, rl_null)
goto 1000
end if
c
c End of first pass for phase I
c=======================================================================
c Start of second pass for phase I.
c
700 continue
if (aa_1 .ge. inf) aa_1 = aa_1*0.99d0
psi = xp_nu*psi
mx_pv = zero
aa_fs = inf
aa_ifs = -inf
ix_o_f_fs_vr_t_bd = -1
ix_o_l_ifs_vr_t_bd = -1
rao_fs = inf
rao_ifs = inf
n_cdd_ix0 = n_cdd_ix
n_cdd_ix = 0
cdd_ix_n_o_l_ifs_vr_t_bd = 0
cdd_ix_n_o_f_fs_vr_t_bd = 0
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1) call ems_tt_rec(cz_r_ph_1_ps_2_tt, n_bs)
CM ENDIF
do 710, cdd_ix_n = 1, n_cdd_ix0
ix_n = cdd_ix(cdd_ix_n)
pv = nw_eta_v(ix_n)
c NO_SGN pv = mv_dir*pv
pv = mv_dir*pv
vr_n = vr_in_r(nw_eta_ix(ix_n))
vr_st = st(vr_n)
if (iand(vr_st, ifs_bt) .ne. 0) then
if (pv .gt. zero) then
rao_ifs = (rsmi_lb(vr_n)-pr_act(vr_n))/pv
if (iand(vr_st, ub_bt) .ne. 0)
& rao_fs = (rsmi_ub(vr_n)-pr_act(vr_n))/pv
else
rao_ifs = (rsmi_ub(vr_n)-pr_act(vr_n))/pv
if (iand(vr_st, lb_bt) .ne. 0)
& rao_fs = (rsmi_lb(vr_n)-pr_act(vr_n))/pv
end if
if (rao_ifs .le. aa_1) then
c
c This infeasible variable may become feasible even if it does not
c become nonbasic. Need to know to check this and change its basic
c cost as a result.
c
n_cdd_ix = n_cdd_ix + 1
cdd_ix(n_cdd_ix) = ix_n
c
c Note that for an infeasible variable rao_fs .le. aa_1 only if
c rao_fs .le. aa_1.
c
if (rao_ifs .gt. aa_ifs .and. abs(pv) .ge. psi) then
aa_ifs = rao_ifs
ix_o_l_ifs_vr_t_bd = ix_n
c
c Note where the current chosen row is in the candidate list.
c
cdd_ix_n_o_l_ifs_vr_t_bd = n_cdd_ix
end if
if (rao_fs .le. aa_1) then
if (abs(pv) .gt. mx_pv) then
aa_fs = rao_fs
ix_o_f_fs_vr_t_bd = ix_n
c
c Note where the current chosen row is in the candidate list.
c
cdd_ix_n_o_f_fs_vr_t_bd = n_cdd_ix
mx_pv = abs(pv)
end if
rao_fs = inf
end if
end if
else
if (pv .gt. zero) then
rao_fs = (rsmi_ub(vr_n)-pr_act(vr_n))/pv
else
rao_fs = (rsmi_lb(vr_n)-pr_act(vr_n))/pv
end if
if (rao_fs .le. aa_1) then
if (abs(pv) .gt. mx_pv) then
aa_fs = rao_fs
ix_o_f_fs_vr_t_bd = ix_n
mx_pv = abs(pv)
end if
rao_fs = inf
end if
end if
710 continue
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_cz_r_lvl1) call ems_tt_rec(-cz_r_ph_1_ps_2_tt, n_bs)
CM ENDIF
if (ix_o_f_fs_vr_t_bd .lt. 0) then
c
c If no variable can exceed its opposite bound then mx_pv will be
c zero so set it to one so that the minimium EXPAND step is
c well-defined.
c
mx_pv = one
if (ix_o_l_ifs_vr_t_bd .lt. 0) then
loop_n = 710
goto 8040
end if
end if
n_ifs_cdd_r = n_cdd_ix
if (ix_o_l_ifs_vr_t_bd .lt. 0) then
c
c No infeasible variables become feasible for a step less than aa_1.
c Simply choose the feasible variable which reaches a bound and has
c the best pivot.
c
ix_o_vr_t_lv_bs = ix_o_f_fs_vr_t_bd
aa = aa_fs
else
if (ix_o_f_fs_vr_t_bd .lt. 0) then
c
c No feasible variable reaches a bound. Simply choose the infeasible
c variable which becomes feasible with biggest step and has an OK
c pivot.
c
ix_o_vr_t_lv_bs = ix_o_l_ifs_vr_t_bd
aa = aa_ifs
else if (ix_o_f_fs_vr_t_bd .eq. ix_o_l_ifs_vr_t_bd) then
c
c The same pivot is chosen both as the last infeasible variable to
c reach a bound with an OK pivot and as the the feasible variable
c which reaches a bound and has the best pivot.
c
ix_o_vr_t_lv_bs = ix_o_f_fs_vr_t_bd
aa = aa_fs
else if (n_ifs_cdd_r .eq. n_ifs_r) then
c
c All the infeasible variables become feasible for a step less than
c aa_1---before a feasible variable reaches its expanded bound.
c Unless the feasible variable which reaches a bound and has the
c best pivot has a pivot which is significantly better, choose the
c infeasible variable which becomes feasible with biggest step and
c has an OK pivot.
c
if (abs(nw_eta_v(ix_o_l_ifs_vr_t_bd)) .gt.
& xp_nu*abs(nw_eta_v(ix_o_f_fs_vr_t_bd))) then
ix_o_vr_t_lv_bs = ix_o_l_ifs_vr_t_bd
aa = aa_ifs
else
ix_o_vr_t_lv_bs = ix_o_f_fs_vr_t_bd
aa = aa_fs
end if
else
c
c Not all infeasible variables become feasible for a step less than
c aa_1. Unless the infeasible variable which reaches a bound and has
c an OK pivot has a pivot which is significantly better, choose the
c feasible variable which reaches a bound and has the best pivot.
c
if (xp_nu*abs(nw_eta_v(ix_o_l_ifs_vr_t_bd)) .gt.
& abs(nw_eta_v(ix_o_f_fs_vr_t_bd))) then
ix_o_vr_t_lv_bs = ix_o_l_ifs_vr_t_bd
aa = aa_ifs
else
ix_o_vr_t_lv_bs = ix_o_f_fs_vr_t_bd
aa = aa_fs
end if
end if
end if
pv = nw_eta_v(ix_o_vr_t_lv_bs)
if (ix_o_vr_t_lv_bs .gt. 0 .and. abs(pv) .lt. ok_pv) then
c
c Growth will occur if this pivot is used: possibly refine the
c pivotal column.
c
if (iand(cz_r_msk, cz_r_refine_bt) .ne. 0 .and.
& .not. refined_pv_c) then
c
c Set up the values required to monitor growth.
c
pv_r_n = nw_eta_ix(ix_o_vr_t_lv_bs)
vr_n = vr_in_r(pv_r_n)
growth = abs(mx_pv_c_v/pv)
CM IF (emsol_dev .EQ. 1) THEN
C? call ems_mo_rsmi_growth(n_si_it, growth_act_refine_pv_c,
C? & pv_r_n, vr_n, pv, aa, growth, zero, 0)
CM ENDIF
refine_pv_c = .true.
rp_growth = .true.
goto 7000
end if
end if
c call ems_rp_cz_r(lp_ph, n_r+1, 0, aa_1, aa_fs, aa_ifs, rl_null)
c call ems_rp_cz_r(lp_ph, n_r+2,
c & 0, aa, mx_pv_c_v, rl_null, rl_null)
c
c End of second pass for phase I.
c=======================================================================
c
c End of phase I cz_r
c=======================================================================
1000 continue
if (abs(pv) .lt. cz_r_pv_tl) then
call ems_ck_cz_r_pv(
& pv_c_v, nw_eta_v, nw_eta_ix,
& nw_eta_f_ix, nw_eta_l_ix,
& ix_o_vr_t_lv_bs,
& prev_n_ix, rpt_cz_r, alg_er)
if (alg_er) goto 7000
if (rpt_cz_r) goto 100
endif
CM IF (dvx .EQ. 1) THEN
C? if (ed_wt_o_vr_t_en_bs .gt. one) then
C? ed_wt_o_vr_t_en_bs = sqrt(ed_wt_o_vr_t_en_bs)
C? else
C? ed_wt_o_vr_t_en_bs = one
C? endif
C? dvx_rao = max(
C? & ed_wt_o_vr_t_en_bs/og_ed_wt_o_vr_t_en_bs,
C? & og_ed_wt_o_vr_t_en_bs/ed_wt_o_vr_t_en_bs)
C? i_te = n_r/nw_dvx_fwk_fq
C? i_te = max(mn_n_dvx_it, i_te)
C? nw_dvx_fwk = dvx_rao .gt. tl_dvx_wt .or. n_dvx_it .gt. i_te
CM IF (emsol_dev .EQ. 1) THEN
C? if (nw_dvx_fwk) call ems_mo_rsmi_nw_dvx_fwk(n_si_it,
C? & n_dvx_it, i_te, dvx_rao, tl_dvx_wt)
CM ENDIF
C? ed_wt(vr_t_en_bs) = ed_wt_o_vr_t_en_bs
CM ENDIF
CM IF (sed .EQ. 1) THEN
ed_wt_o_vr_t_en_bs = ed_wt_o_vr_t_en_bs*half
ed_wt_er = abs((
& og_ed_wt_o_vr_t_en_bs-ed_wt_o_vr_t_en_bs)/
& og_ed_wt_o_vr_t_en_bs)
if (ed_wt_er .gt. mx_ed_wt_er) then
mx_ed_wt_er = ed_wt_er
if (iand(rsmi_msg_msk, rsmi_er_li_bt) .ne. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9500)
& n_si_it, 'Stpst edge wt:',
& ' U_STPST_ED_WT', og_ed_wt_o_vr_t_en_bs,
& ' FTRAN', ed_wt_o_vr_t_en_bs, ed_wt_er
call ems_msg_wr_li(warn_msg_n)
end if
end if
ed_wt(vr_t_en_bs) = ed_wt_o_vr_t_en_bs
CM ENDIF
vr_t_lv_bs = vr_in_r(nw_eta_ix(ix_o_vr_t_lv_bs))
CM IF (emsol_dev .EQ. 1) THEN
C? if (ts_parsmi .gt. 0) then
C? if (vr_t_lv_bs .ne. rd_lv_vr_n) then
C? do 9991, ix_n = nw_eta_f_ix, nw_eta_l_ix
C? if (vr_in_r(nw_eta_ix(ix_n)) .eq. rd_lv_vr_n) then
C? vr_t_lv_bs = rd_lv_vr_n
C? ix_o_vr_t_lv_bs = ix_n
C? pv = nw_eta_v(ix_n)
C?c NO_SGN pv = mv_dir*pv
C? pv = mv_dir*pv
C? if (pv .gt. zero) then
C? aa = (rsmi_ub(vr_n) - pr_act(vr_n))/pv
C? else
C? aa = (rsmi_lb(vr_n) - pr_act(vr_n))/pv
C? endif
C? goto 9992
C? endif
C? 9991 continue
C? print*, 'Cannot find variable ', rd_lv_vr_n
C? stop
C? 9992 continue
C? endif
C? endif
CM ENDIF
if (mx_pv .eq. zero) goto 8090
aa = max(aa, xp_tau/mx_pv)
if (aa .ge. inf) goto 8010
if (aa .lt. zero) goto 8020
if (ix_o_vr_t_lv_bs .gt. 0 .and.
& abs(pv) .lt. ok_pv*1d1 .and. abs(pv) .ge. ok_pv) then
c
c Near-growth has occurred so maybe monitor it.
c
c Set up the values required to monitor growth.
c
pv_r_n = nw_eta_ix(ix_o_vr_t_lv_bs)
vr_n = vr_in_r(pv_r_n)
growth = abs(mx_pv_c_v/pv)
CM IF (emsol_dev .EQ. 1) THEN
C? call ems_mo_rsmi_growth(n_si_it, growth_act_nr_growth,
C? & pv_r_n, vr_n, pv, aa, growth, zero, 0)
CM ENDIF
else if (ix_o_vr_t_lv_bs .gt. 0 .and. abs(pv) .lt. ok_pv) then
c
c Potential growth has been detected and the pivotal column has
c already been refined if this option has been selected.
c
c Set up the values required to monitor growth.
c
pv_r_n = nw_eta_ix(ix_o_vr_t_lv_bs)
vr_n = vr_in_r(pv_r_n)
growth = abs(mx_pv_c_v/pv)
growth_mode = iand(cz_r_msk, cz_r_growth_mode)
if (growth_mode .eq. cz_r_growth_inv .and. n_u .gt. 0) then
c