-
Notifications
You must be signed in to change notification settings - Fork 2
/
dan_cz_c.f
394 lines (393 loc) · 12.1 KB
/
dan_cz_c.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
C->>> ----------------------------------------------> ems_dan_cz_1_c <<<
c Returns the best candidate variable from the set of candidates.
c If bst_vr_n = 0 then none of the candidates is attractive.
c
subroutine ems_dan_cz_1_c(
& bp_swp_sd, en_c_n, en_sn_n,
& rsmi_lb, rsmi_ub, st,
& vr_in_c, du_act)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'RSMICS.INC'
include 'RSMICOM.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
include 'RLCTVR.INC'
integer bp_swp_sd, en_c_n, en_sn_n
double precision rsmi_lb(0:mx_n_c+n_r)
double precision rsmi_ub(0:mx_n_c+n_r)
integer st(0:mx_n_c+n_r)
integer vr_in_c(-vr_in_c_n_sn:n_c)
double precision du_act(0:mx_n_c+n_r)
integer c_n, vr_n
double precision vr_du_act, abs_vr_du_act
double precision mx_abs_vr_du_act
mx_abs_vr_du_act = tl_du_ifs
do 10, c_n = 1, vr_in_c(os_lg_in_c_ab_bp_p)
c
c Above break point:
c
vr_n = vr_in_c(c_n)
c
c lb:co:ub are bp:uco:lco-uco
c
c Free to move up with given dual activity
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
bp_swp_sd = 0
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: With convex cost functions it cannot be attractive to move
c both ways.
c
c Free to move down with modified dual activity
c
vr_du_act = vr_du_act + pr_co_mu*rsmi_ub(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
bp_swp_sd = -1
c
c Record the column and section number in order to swap sides if
c this variable is chosen.
c
en_c_n = c_n
en_sn_n = lg_sn_n_os + vr_in_c_sn_ty_ab_bp
end if
end if
10 continue
do 20, c_n = c_n, vr_in_c(os_lg_in_c_bw_bp_p)
c
c Below break point:
c
vr_n = vr_in_c(c_n)
c
c lb:co:ub are uco-lco:lco:bp
c
c Free to move down with given dual activity
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
bp_swp_sd = 0
else if (-vr_du_act .gt. tl_du_ifs) then
c
c NB: With convex cost functions it cannot be attractive to move
c both ways.
c
c Free to move up with modified dual activity
c
vr_du_act = vr_du_act + pr_co_mu*rsmi_lb(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
bp_swp_sd = 1
c
c Record the column and section number in order to swap sides if
c this variable is chosen.
c
en_c_n = c_n
en_sn_n = lg_sn_n_os + vr_in_c_sn_ty_bw_bp
end if
end if
20 continue
do 30, c_n = c_n, vr_in_c(os_lg_in_c_up_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move up or down with given dual activity.
c
abs_vr_du_act = abs(du_act(vr_n))
if (abs_vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = abs_vr_du_act
c
c Set bp_swp_sd = 0 in case this is a breakpoint variable.
c
bp_swp_sd = 0
end if
30 continue
if (lp_ph .eq. 1 .and.
& iand(cz_c_msk, cz_c_bk_bd_bt) .ne. 0) then
do 40, c_n = c_n, vr_in_c(os_lg_in_c_up_p)
vr_n = vr_in_c(c_n)
c
c Free to move up (from lower bound) with given dual activity.
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move up from a bound and down
c through it.
c
c Free to move down (through bound) with modified dual activity
c
vr_du_act = vr_du_act - one
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
end if
40 continue
do 45, c_n = c_n, vr_in_c(os_lg_in_c_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move down (from upper bound) with given dual activity.
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
else if (-vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move down from a bound and up
c through it.
c
c Free to move up (through bound) with modified dual activity
c
vr_du_act = vr_du_act + one
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
end if
end if
45 continue
c
c Consider moving from a (temporarily) fixed value.
c
do 47, c_n = c_n, vr_in_c(os_lg_in_c_te_fx_p)
vr_n = vr_in_c(c_n)
vr_du_act = du_act(vr_n) + one
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move up from a fixed value and down
c from it
c
c It is attractive to move down from a fixed value.
c
vr_du_act = du_act(vr_n) - one
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
end if
47 continue
else
do 50, c_n = c_n, vr_in_c(os_lg_in_c_up_p)
vr_n = vr_in_c(c_n)
c
c Free to move up with given dual activity.
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
end if
50 continue
do 55, c_n = c_n, vr_in_c(os_lg_in_c_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move down with given dual activity.
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
55 continue
endif
do 110, c_n = vr_in_c(os_struc_in_c_f_p_m1) + 1,
& vr_in_c(os_struc_in_c_ab_bp_p)
c
c Above break point:
c
vr_n = vr_in_c(c_n)
c
c lb:co:ub are bp:uco:lco-uco
c
c Free to move up with given dual activity
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
bp_swp_sd = 0
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: With convex cost functions it cannot be attractive to move
c both ways.
c
c Free to move down with modified dual activity
c
vr_du_act = vr_du_act + pr_co_mu*rsmi_ub(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
bp_swp_sd = -1
c
c Record the column and section number in order to swap sides if
c this variable is chosen.
c
en_c_n = c_n
en_sn_n = struc_sn_n_os + vr_in_c_sn_ty_ab_bp
end if
end if
110 continue
do 120, c_n = c_n, vr_in_c(os_struc_in_c_bw_bp_p)
c
c Below break point:
c
vr_n = vr_in_c(c_n)
c
c lb:co:ub are uco-lco:lco:bp
c
c Free to move down with given dual activity
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
bp_swp_sd = 0
else if (-vr_du_act .gt. tl_du_ifs) then
c
c NB: With convex cost functions it cannot be attractive to move
c both ways.
c
c Free to move up with modified dual activity
c
vr_du_act = vr_du_act + pr_co_mu*rsmi_lb(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
bp_swp_sd = 1
c
c Record the column and section number in order to swap sides if
c this variable is chosen.
c
en_c_n = c_n
en_sn_n = struc_sn_n_os + vr_in_c_sn_ty_bw_bp
end if
end if
120 continue
do 130, c_n = c_n, vr_in_c(os_struc_in_c_up_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move up or down with given dual activity.
c
abs_vr_du_act = abs(du_act(vr_n))
if (abs_vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = abs_vr_du_act
c
c Set bp_swp_sd = 0 in case this is a breakpoint variable.
c
bp_swp_sd = 0
end if
130 continue
if (lp_ph .eq. 1 .and.
& iand(cz_c_msk, cz_c_bk_bd_bt) .ne. 0) then
do 140, c_n = c_n, vr_in_c(os_struc_in_c_up_p)
vr_n = vr_in_c(c_n)
c
c Free to move up (from lower bound) with given dual activity.
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move up from a bound and down
c through it.
c
c Free to move down (through bound) with modified dual activity
c
vr_du_act = vr_du_act - one
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
end if
140 continue
do 145, c_n = c_n, vr_in_c(os_struc_in_c_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move down (from upper bound) with given dual activity.
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
else if (-vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move down from a bound and up
c through it.
c
c Free to move up (through bound) with modified dual activity
c
vr_du_act = vr_du_act + one
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
end if
end if
145 continue
c
c Consider moving from a (temporarily) fixed value.
c
do 147, c_n = c_n, vr_in_c(os_struc_in_c_te_fx_p)
vr_n = vr_in_c(c_n)
vr_du_act = du_act(vr_n) + one
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
else if (vr_du_act .gt. tl_du_ifs) then
c
c NB: It cannot be attractive to move up from a fixed value and down
c from it
c
c It is attractive to move down from a fixed value.
c
vr_du_act = du_act(vr_n) - one
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
end if
147 continue
else
do 150, c_n = c_n, vr_in_c(os_struc_in_c_up_p)
vr_n = vr_in_c(c_n)
c
c Free to move up with given dual activity.
c
vr_du_act = du_act(vr_n)
if (-vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = -vr_du_act
end if
150 continue
do 155, c_n = c_n, vr_in_c(os_struc_in_c_dn_p)
vr_n = vr_in_c(c_n)
c
c Free to move down with given dual activity.
c
vr_du_act = du_act(vr_n)
if (vr_du_act .gt. mx_abs_vr_du_act) then
nx_vr_t_en_bs = vr_n
mx_abs_vr_du_act = vr_du_act
end if
155 continue
endif
return
end