-
Notifications
You must be signed in to change notification settings - Fork 2
/
rsmi.f
2349 lines (2333 loc) · 81.2 KB
/
rsmi.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_rsmi <<<
c
c This routine solves the bounded LP problem
c
c minimize mx_mn*c^x
c
c subject to l < = [ x] < = u
c [Ax]
c
c where x and c are n-vectors, and A is an n*m matrix.
c
c Parameter list
c
c ds double precision workspace | Equivalenced
c is integer workspace |
c
subroutine ems_rsmi(ds, is, lp_iz_mode)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'EMSPM.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMICS.INC'
include 'RSMIHDL.INC'
include 'RSMICOM.INC'
include 'MORSMI.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
c include 'CHCTVR.INC' !Only needed when dumping basis
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
include 'ITXITCS.INC'
c include 'SVMVBD.INC'
CM IF (emsol_tt .EQ. 1) THEN
C? include 'EMSTT.INC'
CM ENDIF
CM IF (emsol_xa .EQ. 1) THEN
C?c include 'CRASH.INC'
CM ENDIF
c include 'TSRGACT.INC'
include 'EMSMMGRI.INC'
include 'EMSRTCOD.INC'
integer ems_rt_cod
integer is(0:is_n_en_m1)
double precision ds(0:ds_n_en_m1)
integer lp_iz_mode
integer ems_pos_mod
logical ems_du_act_atr
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
CM ENDIF
logical du_act_sgn_ok, re_re_pc
logical u_du_act, u_ed_wt, re_pc
logical rp_growth, refine_pv_c, refined_pv_c
integer reset_rsmi_n_si_it
integer it_xit_reason, usr_rt_cod
integer usr_msg_fq, usr_rsmi_msg_msk, usr_wr_lp_da, usr_ck_msk
CM IF (emsol_dev .EQ. 1) THEN
C? integer du_act_er_why
CM ENDIF
logical du_act_atr
double precision alt_du_act, du_act_er
double precision mx_ed_wt_er, mx_du_act_er, mx_pv_er
double precision norm_rsdu
integer ftran_sol_n_en
integer rhs_sgn
integer ems_i_t_i_pct
integer pct
integer poss_sps_sto_ftran_ix_y_n_it
integer poss_sps_sto_btran_ix_y_n_it
integer poss_sps_sto_tbu_r_ix_y_n_it
integer poss_sps_fwd_eta_p_n_inv
integer poss_sps_r_eta_fi_n_inv
integer poss_sps_bwd_eta_p_n_inv
integer poss_sps_n_inv
integer poss_sps_n_si_it0
logical reset_loop
c integer r_n
c logical er_fd
c integer ca_ems_rt_cod
c integer ems_ln_t_l_ch
c integer ml_nm_ln
save usr_msg_fq, usr_rsmi_msg_msk, usr_wr_lp_da, usr_ck_msk
CM IF (emsol_epc .EQ. 1) THEN
C?c
C?c Have to use a function compiled without unassigned variable
C?c checking in order to test values which may be unassigned.
C?c
C? if (ems_i1_eq_i2(iz_bt_a_com_fg1, iz_bt_a_com_fg2))
CM ELSE
if (iz_bt_a_com_fg1 .eq. iz_bt_a_com_fg2)
CM ENDIF
& call ems_iz_bt_a_com
CM IF (emsol_dev .EQ. 1) THEN
CM IF (emsol_epc .EQ. 1) THEN
C?c
C?c Have to use a function compiled without unassigned variable
C?c checking in order to test values which may be unassigned.
C?c
C? if (ems_i1_eq_i2(ca_iz_mo_rsmi_fg1, ca_iz_mo_rsmi_fg2))
CM ELSE
C? if (ca_iz_mo_rsmi_fg1 .eq. ca_iz_mo_rsmi_fg2)
CM ENDIF
C? & call ems_iz_mo_rsmi(11, 2, 0)
CM ENDIF
ems_rt_cod = ems_rt_cod_ok
bd_swp = .false.
fresh_pc = .false.
re_pc = .false.
u_du_act = .false.
u_ed_wt = .false.
cg_pr_wt = .false.
rp_growth = .false.
c n_sv_mv_bd = 0
pc_alg = dvx_mode
mx_ed_wt_er = tl_ed_wt_er
mx_du_act_er = tl_du_act_er
mx_pv_er = tl_pv_er
if (lp_iz_mode .eq. 1) then
if (sto_btran_ix_mode .eq. sto_ix_y) then
sto_btran_ix = sto_ix_y
else if (sto_btran_ix_mode .eq. sto_ix_no) then
sto_btran_ix = sto_ix_no
else
sto_btran_ix = sto_ix_y
endif
if (sto_ftran_ix_mode .eq. sto_ix_y) then
sto_ftran_ix = sto_ix_y
else if (sto_ftran_ix_mode .eq. sto_ix_no) then
sto_ftran_ix = sto_ix_no
else
sto_ftran_ix = sto_ix_y
endif
endif
c
c Report on the initial pricing strategy
c
if (iand(rsmi_msg_msk, rsmi_pc_li_bt) .ne. 0) then
if (pc_alg .eq. pc_alg_dan) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& 'Dantzig'
else if (pc_alg .eq. pc_alg_approx_dvx .or.
& pc_alg .eq. pc_alg_exact_dvx) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& 'Devex'
else if (pc_alg .eq. pc_alg_sed) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& 'steepest edge'
endif
call ems_msg_wr_li(info_msg_n)
endif
reset_rsmi_n_si_it = n_si_it - 1
CM IF (emsol_da .EQ. 1) THEN
C?c
C?c Keep a copy of the original basis to determine how good it was
C?c
C? call ems_rsmi_da(1, ds, is)
C? if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
C?c ml_nm_ln = ems_ln_t_l_ch(ch_ml_nm)
C?c open(unit = 7, file = ch_ml_nm(1:ml_nm_ln)//'.sps_da')
C? open(unit = 7, file = 'ml.sps_da')
C? write(7, 9370)
CM ENDIF
c=======================================================================
c Start of major iteration: Sections
c CHUZC
c (M)FTRAN
c CHUZR
c UPDATE
c INVERT
c PRICE
c
CM IF (emsol_dev .EQ. 1) THEN
C? if (ts_parsmi .gt. 0) call ems_ck_parsmi_v(0, ds, is)
CM ENDIF
poss_sps_sto_ftran_ix_y_n_it = 0
poss_sps_sto_btran_ix_y_n_it = 0
poss_sps_sto_tbu_r_ix_y_n_it = 0
poss_sps_fwd_eta_p_n_inv = 0
poss_sps_r_eta_fi_n_inv = 0
poss_sps_bwd_eta_p_n_inv = 0
poss_sps_n_si_it0 = n_si_it
poss_sps_n_inv = 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_fwd_p) .ne. 0)
& poss_sps_fwd_eta_p_n_inv = poss_sps_fwd_eta_p_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0)
& poss_sps_r_eta_fi_n_inv = poss_sps_r_eta_fi_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_bwd_p) .ne. 0)
& poss_sps_bwd_eta_p_n_inv = poss_sps_bwd_eta_p_n_inv + 1
1000 continue
CM IF (emsol_da .EQ. 1) THEN
C? call ems_rsmi_da(2, ds, is)
C? if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
CM ENDIF
CM IF (emsol_deb .EQ. 1) THEN
C?c print*, 'Checking vr_in_r: n_si_it = ', n_si_it
C?c call ems_ck_rpt_vr(er_fd, n_r, mx_n_c+n_r, is(p_vr_in_r+1))
C?c if (er_fd) goto 8800
CM ENDIF
if (it_o_sw_fm_wr_df .gt. 0) then
if (n_si_it .eq. 0) then
usr_msg_fq = msg_fq
usr_rsmi_msg_msk = rsmi_msg_msk
usr_wr_lp_da = wr_lp_da
msg_fq = i_ct_vr_df(ix_msg_fq)
rsmi_msg_msk = i_ct_vr_df(ix_rsmi_msg_msk)
wr_lp_da = i_ct_vr_df(ix_wr_lp_da)
else if (n_si_it .eq. it_o_sw_fm_wr_df) then
msg_fq = usr_msg_fq
rsmi_msg_msk = usr_rsmi_msg_msk
wr_lp_da = usr_wr_lp_da
endif
endif
if (it_o_sw_fm_ck_df .gt. 0) then
if (n_si_it .eq. 0) then
usr_ck_msk = ck_msk
ck_msk = i_ct_vr_df(ix_ck_msk)
else if (n_si_it .eq. it_o_sw_fm_ck_df) then
ck_msk = usr_ck_msk
endif
endif
if (ck_msk .ne. 0) call ems_ck_lp_da(ds, is)
c=======================================================================
c CHUZC section
c
call ems_rsmi_cz_c_sn(ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
CM IF (emsol_dev .EQ. 1) THEN
C? if (ts_parsmi .gt. 0) call ems_ck_parsmi_v(1, ds, is)
C? if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
CM ENDIF
c if (ts_rg_act_en_vr .ne. 0) call ems_ts_rg_act_rn(1, ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
c
c Allow a user exit at this point.
c
c The dual activities may change because
c * the user has tightened bounds and the current vertex is not
c . feasible;
c * the user has changed costs.
c
c The problem may no longer be optimal because the user has
c relaxed bounds.
c
c In either event, the rsmi_op_st_cz_c bit is un-set. Thand the
c fact that it_xit_reason.eq.it_xit_af_cz_c, ensures that cz_1_c is
c called within it_xit and a new value is assigned to vr_t_en_bs
c
if (ems_pos_mod(n_si_it, it_usr_xit_fq) .eq. 0) then
it_xit_reason = it_xit_af_cz_c
call ems_it_xit(ds, is, it_xit_reason, usr_rt_cod)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (usr_rt_cod .eq. 3) then
prob_st = prob_st_mx_n_it
rq_reset = rq_reset_no_rq_reset
go to 3000
else if (usr_rt_cod .eq. 99) then
reset_rsmi_n_si_it = -1
rq_reset = rq_reset_usr_rq_reset
go to 3000
end if
endif
c
c Check that CHUZC has been performed with the current reduced costs
c and bounds on non-basic variables.
c
if (iand(rsmi_op_st_msk, rsmi_op_st_cz_c) .eq. 0) goto 8000
rsmi_op_st_msk = rsmi_op_st_msk - rsmi_op_st_cz_c
c
c If optimality/infeasibility suspected then reset RSMI.
c
if (vr_t_en_bs .eq. 0) then
if (lp_ph .eq. 1 .and. pr_wt .gt. zero) then
c pr_wt = pr_wt*1d-1
c if (pr_wt .lt. rl_ct_vr_lb(ix_pr_wt)) pr_wt = zero
pr_wt = zero
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9210)pr_wt
call ems_msg_wr_li(info_msg_n)
pr_co_mu = mx_mn*pr_wt
call ems_se_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))
rq_re_pc = rq_re_pc_pr_wt_cg
fresh_pc = .true.
cg_pr_wt = .true.
goto 1500
else
prob_st = prob_st_op
rq_reset = rq_reset_op
go to 3000
end if
endif
du_act_o_vr_t_en_bs = ds(p_du_act+vr_t_en_bs)
if (du_act_o_vr_t_en_bs .lt. zero) then
mv_dir = 1
else
mv_dir = -1
end if
c
c End of CHUZC section
c=======================================================================
c FTRAN section
c
1200 continue
call ems_rsmi_ftran_sn(refined_pv_c, ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
c
c End of FTRAN section
c=======================================================================
c CK_DU_ACT_O_VR_T_EN_BS section
c
c Determine whether the dual activity of the variable to enter the
c basis has the right sign and, in doing so, determine the error in
c the dual activity.
c
rhs_sgn = 1
du_act_o_vr_t_en_bs = ds(p_du_act+vr_t_en_bs)
c if (ts_rg_act_en_vr .ne. 0) go to 1225
CM IF (emsol_tt .EQ. 1) THEN
C? if (g_tt_da .gt. 0) call ems_tt_rec(ck_du_act_tt, n_bs)
CM ENDIF
call ems_g_alt_du_act(
& rhs_sgn, vr_t_en_bs,
& 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_o_vr_t_en_bs, alt_du_act, ph_1_du_act_o_vr_t_en_bs)
if (abs(du_act_o_vr_t_en_bs) .gt. tl_du_ifs) then
du_act_er = abs((du_act_o_vr_t_en_bs-alt_du_act)/
& du_act_o_vr_t_en_bs)
else
du_act_er = abs(du_act_o_vr_t_en_bs-alt_du_act)
end if
c if (du_act_er .gt. 1d-4) print*, n_si_it,
c & ' du_act_er = ', du_act_er
du_act_sgn_ok = du_act_o_vr_t_en_bs*alt_du_act .gt. zero
c
c Monitor wrong signs and increasing dual activity errors
c
if (.not. du_act_sgn_ok .or. du_act_er .gt. mx_du_act_er) then
mx_du_act_er = max(du_act_er, mx_du_act_er)
CM IF (emsol_dev .EQ. 1) THEN
C? if (du_act_sgn_ok) then
C? du_act_er_why = du_act_er_why_er
C? else
C? du_act_er_why = du_act_er_why_wg_sgn
C? endif
C? call ems_mo_rsmi_du_act_er(
C? & n_si_it, du_act_er_why,
C? & du_act_o_vr_t_en_bs, alt_du_act, du_act_er)
CM ENDIF
end if
c
c Determine the action corresponding to the sign/value error.
c
call ems_an_du_act_er(re_pc, re_re_pc,
& du_act_o_vr_t_en_bs, alt_du_act, du_act_sgn_ok, du_act_er)
CM IF (emsol_tt .EQ. 1) THEN
C? if (g_tt_da .gt. 0) call ems_tt_rec(-ck_du_act_tt, n_bs)
CM ENDIF
if (re_re_pc) then
rq_reset = rq_reset_re_re_pc
goto 3000
endif
if (re_pc) then
if (du_act_sgn_ok) then
rq_re_pc = rq_re_pc_du_act_er
else
rq_re_pc = rq_re_pc_du_act_wg_sgn
endif
endif
if (re_pc .or. rq_inv .ne. rq_inv_no_rq_inv) then
c
c The dual activity has the wrong sign or numerical problems have
c been detected. Abandon this iteration so zero the RHS used for
c FTRAN.
c
call ems_ze_pv_c_v(ds(p_pv_c_v), is(p_nw_eta_ix))
if (re_pc) then
c nw_sgn_er_bug mx_du_act_er = tl_du_act_er
go to 1500
endif
c
c Set re_pc for u_pc=0 now or set re_pc in ems_an_du_act_er
c Don't re-price for u_pc=0 if fresh INVERT . Maybe jump on
c rq_inv .ne. rq_inv_no_rq_inv
c
go to 1400
end if
c
c Use the dual activity which was calculated to test the sign rather
c than the original value.
c
ds(p_du_act+vr_t_en_bs) = alt_du_act
du_act_o_vr_t_en_bs = alt_du_act
c 1225 continue
c
c Indicate the direction in which the entering variable is moving.
c Hereafter du_act_o_vr_t_en_bs is only used by wr_rsmi_lg_li and
c L1-CHUZR.
c
if (lp_ph .eq. 1) then
if (en_vr_bk_bd .lt. 0) then
c
c The entering variable is breaking through its lower bound or
c moving below a fixed value.
c Modify the dual activity and phase I dual activity accordingly and
c test for phase I attractiveness.
c
du_act_o_vr_t_en_bs = du_act_o_vr_t_en_bs - one
ph_1_du_act_o_vr_t_en_bs = ph_1_du_act_o_vr_t_en_bs - one
du_act_atr = ph_1_du_act_o_vr_t_en_bs .gt. tl_du_ifs
else if (en_vr_bk_bd .gt. 0) then
c
c The entering variable is breaking through its upper bound or
c moving above a fixed value.
c Modify the dual activity and phase I dual activity accordingly and
c test for phase I attractiveness.
c
du_act_o_vr_t_en_bs = du_act_o_vr_t_en_bs + one
ph_1_du_act_o_vr_t_en_bs = ph_1_du_act_o_vr_t_en_bs + one
du_act_atr = ph_1_du_act_o_vr_t_en_bs .lt. -tl_du_ifs
else
du_act_atr = ems_du_act_atr(is(p_st+vr_t_en_bs),
& ph_1_du_act_o_vr_t_en_bs, tl_du_ifs)
endif
if (du_act_atr) then
cg_pr_wt = .false.
if (ph_1_du_act_o_vr_t_en_bs .lt. zero) then
mv_dir = 1
else
mv_dir = -1
end if
c
c If the entering variable is violating a bound then remove the
c feasibility bit. This is only done temporarily so that it is
c treated correctly in CHUZR. It does not actually become infeasible
c unless a sufficiently large step is made.
c
if (en_vr_bk_bd .ne. 0)
& is(p_st+vr_t_en_bs) = is(p_st+vr_t_en_bs) + ifs_bt
else
c
c The variable is not attractive in the pure phase 1 sense. This
c indicates that the primal wright is too large.
c
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9200)
& ph_1_du_act_o_vr_t_en_bs
call ems_msg_wr_li(info_msg_n)
if (pr_wt .gt. zero) then
pr_wt = pr_wt*1d-1
if (pr_wt .lt. rl_ct_vr_lb(ix_pr_wt)) pr_wt = zero
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9210)pr_wt
call ems_msg_wr_li(info_msg_n)
pr_co_mu = mx_mn*pr_wt
call ems_se_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))
if (pc_alg .eq. pc_alg_sed)
& call ems_ze_pv_c_v(ds(p_pv_c_v), is(p_nw_eta_ix))
rq_re_pc = rq_re_pc_pr_wt_cg
fresh_pc = .true.
cg_pr_wt = .true.
goto 1500
else
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9220)
call ems_msg_wr_li(er_msg_n)
rq_reset = rq_reset_ze_pr_wr
goto 3000
c call ems_msg_wr_li(bug_msg_n)
c goto 7000
endif
endif
else
if (du_act_o_vr_t_en_bs .lt. zero) then
mv_dir = 1
else
mv_dir = -1
end if
endif
CM IF (emsol_dev .EQ. 1) THEN
C? if (ts_parsmi .gt. 0) call ems_ck_parsmi_v(6, ds, is)
CM ENDIF
c
c End of CK_DU_ACT_O_VR_T_EN_BS section
c=======================================================================
c CHUZR section
c
c Find vr_t_lv_bs which, if equal to vr_t_en_bs, indicates a bound
c swap or detect unboundedness.
c
1250 continue
call ems_cz_r(
& rp_growth, refined_pv_c, refine_pv_c, mx_ed_wt_er,
& ds(p_rsmi_lb),
& ds(p_rsmi_ub),
& ds(p_pr_act),
& is(p_st),
& is(p_vr_in_r),
& ds(p_nw_eta_v),
& ds(p_pv_c_v),
& is(p_nw_eta_ix),
& is(p_cz_r_cdd_ix),
& ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (ck_msk .gt. 0) then
call ems_ck_ftran(
& rhs_sgn,
& ds(p_nw_eta_v),
& ds(p_pv_c_v),
& is(p_nw_eta_ix),
& norm_rsdu,
& ds, is)
if (norm_rsdu .gt. 1d-4) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9030)
& n_si_it+1, norm_rsdu
call ems_msg_wr_li(info_msg_n)
endif
endif
if (refine_pv_c) then
call ems_refine_pv_c(
& rhs_sgn,
& ds(p_nw_eta_v),
& ds(p_pv_c_v),
& is(p_nw_eta_ix),
& is(p_vr_in_r),
& ds, is)
refined_pv_c = .true.
goto 1250
endif
c if (ts_rg_act_en_vr .ne. 0) then
c call ems_ts_rg_act_rn(2, ds, is)
c goto 7000
c endif
if (rq_inv .eq. rq_inv_u_growth) then
c
c Reinvert and recalculate the pivotal column. Note that this event
c can only occur if at least one UPDATE has been performed so an
c infinite loop cannot be caused.
c
if (pc_alg .eq. pc_alg_sed)
& call ems_ze_pv_c_v(ds(p_pv_c_v), is(p_nw_eta_ix))
call ems_rsmi_inv(ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (n_inv_sing .gt. 0) then
rq_reset = rq_reset_sing_bs
goto 3000
endif
poss_sps_n_inv = poss_sps_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_fwd_p) .ne. 0)
& poss_sps_fwd_eta_p_n_inv = poss_sps_fwd_eta_p_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0)
& poss_sps_r_eta_fi_n_inv = poss_sps_r_eta_fi_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_bwd_p) .ne. 0)
& poss_sps_bwd_eta_p_n_inv = poss_sps_bwd_eta_p_n_inv + 1
c
c Maybe re-form the vector of basic costs.
c
if (iand(inv_alg_msk, inv_alg_perm) .eq. 0)
& call ems_se_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))
go to 1200
else if (alg_er) then
prob_st = prob_st_unknown
rq_reset = rq_reset_cz_r_alg_er
go to 3000
else if (un_bd) then
prob_st = prob_st_unbd
if (iand(ml_blk_st_msk, ml_blk_st_ml_aux_sol) .eq. 0) then
call ems_iz_blk_ml_aux_sol(is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
endif
call ems_un_bd_aux_sol(
& is(p_vr_in_r),
& ds(p_nw_eta_v),
& is(p_nw_eta_ix),
& ds(p_r_aux_sol),
& ds(p_c_aux_sol))
rq_reset = rq_reset_unbd
go to 3000
end if
c
c Reinstate the feasibility bit for the entering variable if it was
c attractive for it to break a bound or move from a fixed value.
c
if (en_vr_bk_bd .ne. 0)
& is(p_st+vr_t_en_bs) = is(p_st+vr_t_en_bs) - ifs_bt
c
c When using exact steepest edge weights the full length vector of
c pivotal column values is not zeroed because it needs to be
c BTRANned (unless there has been a bound swap, in which case it is
c just zeroed now).
c
if (pc_alg .eq. pc_alg_sed) then
if (vr_t_lv_bs .eq. vr_t_en_bs) then
call ems_ze_pv_c_v(ds(p_pv_c_v), is(p_nw_eta_ix))
else
call ems_btran(ds(p_pv_c_v), n_r+1, ds, is)
c
c Calling perm_btran_sol may result in the vector pointed to by
c hdl_pv_c_v being zeroed and swapped with the handle pointing to
c another vector of the same length.
c
if (iand(inv_alg_msk, inv_alg_perm) .ne. 0)
& call ems_perm_btran_sol(
& p_pv_c_v, hdl_pv_c_v, n_r+1, ds, is)
end if
end if
bd_swp = vr_t_lv_bs .eq. vr_t_en_bs
pv = rhs_sgn*ds(p_nw_eta_v)
if (sto_ftran_ix_mode .eq. sto_ix_poss) then
ftran_sol_n_en = nw_eta_l_ix - nw_eta_f_ix + 1
ftran_sol_dse = float(ftran_sol_n_en)/float(n_r)
endif
c
c Write out a log line.
c
if ((iand(rsmi_msg_msk, rsmi_li_bt) .ne. 0 .or.
& iand(rsmi_msg_msk, rsmi_pv_li_bt) .ne. 0) .and.
& ems_pos_mod(n_si_it, msg_fq) .eq. 0) then
call ems_wr_rsmi_lg_li(rsmi_lg_li_mode_fq, ds, is)
endif
CM IF (emsol_da .EQ. 1) THEN
C? call ems_rsmi_da(3, ds, is)
C? if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
CM ENDIF
if (nw_dvx_fwk) then
if (n_dvx_fwk .gt. 0 .and.
& iand(rsmi_msg_msk, rsmi_dvx_li_bt) .ne. 0)
& call ems_wr_rsmi_lg_li(rsmi_lg_li_mode_dvx, ds, is)
call ems_iz_dvx_fwk(
& is(p_vr_in_r),
& is(p_vr_in_c),
& ds(p_ed_wt),
& is(p_dvx_ix))
nw_dvx_fwk = .false.
endif
c
c End of CHUZR section
c=======================================================================
c UPDATE section
c
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_u_lvl0) call ems_tt_rec(al_u_tt, n_bs)
CM ENDIF
call ems_rsmi_u_sn(ds, is)
CM IF (emsol_tt .EQ. 1) THEN
C? if (ems_tt_u_lvl0) call ems_tt_rec(-al_u_tt, n_bs)
CM ENDIF
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (bd_swp) then
c
c Following a bound swap go to the end of the major iteration unless
c it has resulted in (phase 1) basic cost changes.
c
if (is(p_pi_ix) .gt. 0 .or. fresh_pc) goto 1500
go to 2000
end if
c
c End of UPDATE section.
c=======================================================================
c INVERT section
c
1400 continue
if (rq_inv .ne. rq_inv_no_rq_inv) then
call ems_rsmi_inv(ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (n_inv_sing .gt. 0) then
rq_reset = rq_reset_sing_bs
goto 3000
endif
poss_sps_n_inv = poss_sps_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_fwd_p) .ne. 0)
& poss_sps_fwd_eta_p_n_inv = poss_sps_fwd_eta_p_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0)
& poss_sps_r_eta_fi_n_inv = poss_sps_r_eta_fi_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_bwd_p) .ne. 0)
& poss_sps_bwd_eta_p_n_inv = poss_sps_bwd_eta_p_n_inv + 1
if (iand(inv_alg_msk, inv_alg_perm) .eq. 0) then
c
c After an INVERT for which vr_in_r is permuted, re-form the vector
c of basic costs, reset the pivotal row number and indicate that the
c dual activities should be re-calculated.
c
call ems_se_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))
if (.not. bd_swp)
& pv_r_n = iand(is(p_st+vr_t_en_bs), mx_mx_ml_a_dim)
fresh_pc = .true.
rq_re_pc = rq_re_pc_inv
c
c >>>> Introduced 01/06/98
c
c nw_sgn_er_bug else if (mx_pv_er .gt. tl_pv_er .or.
c nw_sgn_er_bug & mx_du_act_er .gt. tl_du_act_er) then
c
c If numerical problems are suspected then indicate that the dual
c activities should be re-calculated.
c
c nw_sgn_er_bug mx_pv_er = tl_pv_er
c nw_sgn_er_bug mx_du_act_er = tl_du_act_er
c nw_sgn_er_bug fresh_pc = .true.
c nw_sgn_er_bug if (mx_pv_er .gt. tl_pv_er) then
c nw_sgn_er_bug rq_re_pc = rq_re_pc_pv_er
c nw_sgn_er_bug else
c nw_sgn_er_bug rq_re_pc = rq_re_pc_du_act_er
c nw_sgn_er_bug endif
c
c Introduced 01/06/98 <<<<
c
endif
end if
c
c End of INVERT section
c=======================================================================
c PRICE section
c
1500 continue
call ems_rsmi_pc_sn(
& u_du_act, u_ed_wt, re_pc,
& mx_pv_er,
& ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
c
c End of PRICE section.
c=======================================================================
c Update sparsity control parameters
c
c If the FTRAN solution density is set to a legal value then update
c the average density.
c
if (sto_ftran_ix_mode .eq. sto_ix_poss) then
if (ftran_sol_dse .ge. zero .and. ftran_sol_dse .le. one) then
av_ftran_sol_dse = fac_long_prd*ftran_sol_dse +
& (one-fac_long_prd)*av_ftran_sol_dse
c
c Consider whether it is worth continuing/starting to maintining
c nonzeros in FTRAN
c
if (av_ftran_sol_dse .gt. 1.5d0*tl_fwd_tran_dse_rhs) then
sto_ftran_ix = sto_ix_no
else
sto_ftran_ix = sto_ix_y
endif
endif
if (sto_ftran_ix .eq. sto_ix_y)
& poss_sps_sto_ftran_ix_y_n_it =
& poss_sps_sto_ftran_ix_y_n_it + 1
endif
if (sto_btran_ix_mode .eq. sto_ix_poss) then
c
c If the BTRAN solution density is set to a legal value then update
c the average density.
c
if (btran_sol_dse .ge. zero .and. btran_sol_dse .le. one) then
av_btran_sol_dse = fac_long_prd*btran_sol_dse +
& (one-fac_long_prd)*av_btran_sol_dse
c
c Consider whether it is worth continuing/starting to maintining
c nonzeros in BTRAN. Note that this depends on whether there is a
c row-wise representation of the eta file.
c
if (iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0) then
if (av_btran_sol_dse .gt. 1.5d0*tl_fwd_tran_dse_rhs) then
sto_btran_ix = sto_ix_no
else
sto_btran_ix = sto_ix_y
endif
else
if (av_btran_sol_dse .gt. 1.5d0*tl_bwd_tran_dse_rhs) then
sto_btran_ix = sto_ix_no
else
sto_btran_ix = sto_ix_y
endif
endif
endif
if (sto_btran_ix .eq. sto_ix_y)
& poss_sps_sto_btran_ix_y_n_it =
& poss_sps_sto_btran_ix_y_n_it + 1
endif
if (sto_tbu_r_ix_mode .eq. sto_ix_poss) then
c
c If the tableau row density is set to a legal value then update
c the average density.
c
if (tbu_r_dse .ge. zero .and. tbu_r_dse .le. one) then
av_tbu_r_dse = fac_long_prd*tbu_r_dse +
& (one-fac_long_prd)*av_tbu_r_dse
c
c Consider whether it is worth continuing/starting to maintining
c nonzeros in the tableau row
c
if (av_tbu_r_dse .gt. 1.5d0*tl_fwd_tran_dse_rhs) then
sto_tbu_r_ix = sto_ix_no
else
sto_tbu_r_ix = sto_ix_y
endif
endif
if (sto_tbu_r_ix .eq. sto_ix_y)
& poss_sps_sto_tbu_r_ix_y_n_it =
& poss_sps_sto_tbu_r_ix_y_n_it + 1
endif
if (sto_ftran_ix_mode .eq. sto_ix_poss .or.
& sto_btran_ix_mode .eq. sto_ix_poss .or.
& sto_tbu_r_ix_mode .eq. sto_ix_poss) then
CM IF (emsol_da .EQ. 1) THEN
C? if (ems_pos_mod(n_si_it, 50) .eq. 1) write(7, 9370)
C? write(7, 9371)
C? & iand(eta_fi_da_st_msk, eta_fi_da_st_fwd_p) .ne. 0,
C? & iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0,
C? & iand(eta_fi_da_st_msk, eta_fi_da_st_bwd_p) .ne. 0,
C? & ftran_sol_dse, av_ftran_sol_dse, sto_ftran_ix,
C? & btran_sol_dse, av_btran_sol_dse, sto_btran_ix,
C? & tbu_r_dse, av_tbu_r_dse, sto_tbu_r_ix, n_pc_vr
CM ENDIF
ftran_sol_dse = two
btran_sol_dse = two
tbu_r_dse = two
endif
if (re_pc .or. cg_pr_wt) go to 1000
if (bd_swp) go to 2000
if (rq_inv .eq. rq_inv_pv_er) then
call ems_rsmi_inv(ds, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (n_inv_sing .gt. 0) then
rq_reset = rq_reset_sing_bs
goto 3000
endif
poss_sps_n_inv = poss_sps_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_fwd_p) .ne. 0)
& poss_sps_fwd_eta_p_n_inv = poss_sps_fwd_eta_p_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_r_eta) .ne. 0)
& poss_sps_r_eta_fi_n_inv = poss_sps_r_eta_fi_n_inv + 1
if (iand(eta_fi_da_st_msk, eta_fi_da_st_bwd_p) .ne. 0)
& poss_sps_bwd_eta_p_n_inv = poss_sps_bwd_eta_p_n_inv + 1
c
c Maybe re-form the vector of basic costs.
c
if (iand(inv_alg_msk, inv_alg_perm) .eq. 0)
& call ems_se_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
c
c End of PRICE section.
c=======================================================================
c End of major iteration.
CM IF (emsol_dev .EQ. 1) THEN
C? if (ts_parsmi .gt. 0) call ems_ck_parsmi_v(5, ds, is)
CM ENDIF
2000 continue
c
c Allow a user exit at this point.
c
c The dual activities may change because
c * the user has tightened bounds and the current vertex is not
c . feasible;
c * the user has changed costs.
c
c The problem may no longer be optimal because the user has
c relaxed bounds.
c
c In either event, the rsmi_op_st_cz_c bit is un-set. This ensures
c that cz_1_c is called at the start of the next iteration. The fact
c that it_xit_reason.ne.it_xit_af_cz_c ensures that cz_1_c is not
c called at in it_xit.
c
if (ems_pos_mod(n_si_it, it_usr_xit_fq) .eq. 0) then
it_xit_reason = it_xit_af_pr_it
call ems_it_xit(ds, is, it_xit_reason, usr_rt_cod)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
if (usr_rt_cod .eq. 3) then
prob_st = prob_st_mx_n_it
rq_reset = rq_reset_no_rq_reset
go to 3000
else if (usr_rt_cod .eq. 99) then
reset_rsmi_n_si_it = -1
rq_reset = rq_reset_usr_rq_reset
go to 3000
end if
endif
c
c=======================================================================
c
if (n_si_it .lt. mx_n_si_it) then
c
c Have to put something here to reset if using EXPAND and tl_pr_ifs
c is greater than wk_tl_pr_ifs.
c
go to 1000
else
prob_st = prob_st_mx_n_it
rq_reset = rq_reset_no_rq_reset
go to 3000
end if
c
c=======================================================================
c Reset RSMI.
c The code jumps to here if there is an indication of
c infeasibility, optimality, unboundedness, status errors and other
c non-serious errors. If simplex iterations have been performed
c since the last such reset the nonbasic primal variables are reset,
c the current basis is inverted and the basic primal and dual
c variables are solved for. Otherwise the code terminates if one of
c the following hold.
c
c * No simplex iteration have been performed since the last reset
c (this includes the recognition of true unboundedness ie
c suspected unboundedness leading to a call to reset_rsmi and then
c suspected unboundedness without a simplex iteration being
c performed);
c
c * The problem is optimal. (Optimality suspected and confirmed
c within reset_rsmi);
c
c * The problem is infeasible. (Infeasiblity suspected and confirmed
c within reset_rsmi);
c
c * The simplex iteration limit has been reached.
c
c
3000 continue
if (prob_st .ne. prob_st_mx_n_it .and.
& n_si_it .gt. reset_rsmi_n_si_it) then
n_reset = n_reset + 1
if (n_u .gt. 0) then
rq_inv = rq_inv_reset_bs
ml_da_st_msk =
& ml_da_st_msk - iand(ml_da_st_msk, ml_da_st_inv)
endif
CM IF (emsol_xa .EQ. 1) THEN
C? if (lp_iz_mode .eq. 1) then
CM ENDIF
call ems_reset_rsmi(reset_loop, ds, is)
CM IF (emsol_xa .EQ. 1) THEN
C? else
C? call ems_nw_reset_rsmi(lp_iz_mode, reset_loop, ds, is)
C? endif
CM ENDIF
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
end if
if (un_bd .and. prob_st .eq. prob_st_unknown)
& prob_st = prob_st_unbd
if (reset_loop) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9700)
call ems_msg_wr_li(er_msg_n)
endif
if (reset_loop .or.
& n_si_it .eq. reset_rsmi_n_si_it .or.
& prob_st .eq. prob_st_op .or.
& prob_st .eq. prob_st_ifs .or.
& prob_st .eq. prob_st_unbd .or.
& prob_st .eq. prob_st_mx_n_it) then
c
c RSMI will terminate.
c
CM IF (emsol_da .EQ. 1) THEN
C? call ems_rsmi_da(4, ds, is)
C? if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
CM ENDIF
c call ems_ca_an_bs_inv(ds, is)
go to 7000
else
reset_rsmi_n_si_it = n_si_it
go to 1000
end if
7000 continue
CM IF (emsol_da .EQ. 1) THEN
C?c call ems_rsmi_da(5, ds, is)
C?c if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7100
C? close(7)
CM ENDIF
poss_sps_n_si_it0 = n_si_it - poss_sps_n_si_it0
if (poss_sps_n_si_it0 .gt. 0) then
if (sto_ftran_ix_mode .eq. sto_ix_y) then
pct = 100
else
pct = ems_i_t_i_pct(poss_sps_sto_ftran_ix_y_n_it,