34 use lapack_interfaces,
only:
dgesv
35 use mpi_f08,
only: mpi_in_place, mpi_max, mpi_min
36 use comm,
only: neko_comm, pe_rank, mpi_real_precision
37 use math,
only: neko_eps
38 use profiler,
only: profiler_start_region, profiler_end_region
44 module subroutine mma_update_cpu(this, iter, x, df0dx, fval, dfdx)
52 class(mma_t),
intent(inout) :: this
53 integer,
intent(in) :: iter
54 real(kind=rp),
dimension(this%n),
intent(inout) :: x
55 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
56 real(kind=rp),
dimension(this%m),
intent(in) :: fval
57 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
59 if (.not. this%is_initialized)
then
60 call neko_error(
"The MMA object is not initialized.")
63 call profiler_start_region(
"MMA gensub")
65 call mma_gensub_cpu(this, iter, x, df0dx, fval, dfdx)
66 call profiler_end_region(
"MMA gensub")
69 call profiler_start_region(
"MMA subsolve")
70 if (this%subsolver .eq.
"dip")
then
71 call mma_subsolve_dip_cpu(this, x)
73 call mma_subsolve_dpip_cpu(this, x)
75 call profiler_end_region(
"MMA subsolve")
77 this%is_updated = .true.
78 end subroutine mma_update_cpu
81 module subroutine mma_kkt_cpu(this, x, df0dx, fval, dfdx)
101 class(mma_t),
intent(inout) :: this
102 real(kind=rp),
dimension(this%n),
intent(in) :: x
103 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
104 real(kind=rp),
dimension(this%m),
intent(in) :: fval
105 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
107 if (this%subsolver .eq.
"dip")
then
108 call mma_dip_kkt_cpu(this, x, df0dx, fval, dfdx)
110 call mma_dpip_kkt_cpu(this, x, df0dx, fval, dfdx)
112 end subroutine mma_kkt_cpu
116 module subroutine mma_dpip_kkt_cpu(this, x, df0dx, fval, dfdx)
136 class(mma_t),
intent(inout) :: this
137 real(kind=rp),
dimension(this%n),
intent(in) :: x
138 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
139 real(kind=rp),
dimension(this%m),
intent(in) :: fval
140 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
142 real(kind=rp) :: rez, rezeta
143 real(kind=rp),
dimension(this%m) :: rey, relambda, remu, res
144 real(kind=rp),
dimension(this%n) :: rex, rexsi, reeta
145 real(kind=rp),
dimension(3*this%n+4*this%m+2) :: residual
147 real(kind=rp),
dimension(4*this%m+2) :: residual_small
149 real(kind=rp) :: re_sq_norm
151 rex = df0dx + matmul(transpose(dfdx), this%lambda%x) &
152 - this%xsi%x + this%eta%x
153 rey = this%c%x + this%d%x*this%y%x - this%lambda%x - this%mu%x
154 rez = this%a0 - this%zeta - dot_product(this%lambda%x, this%a%x)
156 relambda = fval - this%a%x * this%z - this%y%x + this%s%x
157 rexsi = this%xsi%x * (x - this%xmin%x)
158 reeta = this%eta%x * (this%xmax%x - x)
159 remu = this%mu%x * this%y%x
160 rezeta = this%zeta * this%z
161 res = this%lambda%x * this%s%x
163 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
164 residual_small = [rey, rez, relambda, remu, rezeta, res]
166 this%residumax = maxval(abs(residual))
167 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
169 call mpi_allreduce(mpi_in_place, this%residumax, 1, &
170 mpi_real_precision, mpi_max, neko_comm, ierr)
172 call mpi_allreduce(mpi_in_place, re_sq_norm, 1, &
173 mpi_real_precision, mpi_sum, neko_comm, ierr)
175 this%residunorm = sqrt(norm2(residual_small)**2 + re_sq_norm)
176 end subroutine mma_dpip_kkt_cpu
180 module subroutine mma_dip_kkt_cpu(this, x, df0dx, fval, dfdx)
200 class(mma_t),
intent(inout) :: this
201 real(kind=rp),
dimension(this%n),
intent(in) :: x
202 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
203 real(kind=rp),
dimension(this%m),
intent(in) :: fval
204 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
206 real(kind=rp),
dimension(this%m) :: relambda, remu
207 real(kind=rp),
dimension(2*this%m) :: residual
210 relambda = fval - this%a%x * this%z - this%y%x + this%mu%x
212 remu = this%lambda%x * this%mu%x
214 residual = abs([relambda, remu])
215 this%residumax = maxval(residual)
216 this%residunorm = norm2(residual)
218 end subroutine mma_dip_kkt_cpu
224 subroutine mma_gensub_cpu(this, iter, x, df0dx, fval, dfdx)
230 class(mma_t),
intent(inout) :: this
231 real(kind=rp),
dimension(this%n),
intent(in) :: x
232 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
233 real(kind=rp),
dimension(this%m),
intent(in) :: fval
234 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
235 integer,
intent(in) :: iter
236 integer :: i, j, ierr
237 real(kind=rp),
dimension(this%n) :: x_diff
238 real(kind=rp) :: asy_factor
240 x_diff = this%xmax%x - this%xmin%x
244 associate(low => this%low%x, upp => this%upp%x, &
245 x_1 => this%xold1%x, x_2 => this%xold2%x)
247 if (iter .lt. 3)
then
249 low = x - this%asyinit * x_diff
250 upp = x + this%asyinit * x_diff
253 if ((x(j) - x_1(j)) * (x_1(j) - x_2(j)) .lt. 0.0_rp)
then
254 asy_factor = this%asydecr
255 else if ((x(j) - x_1(j)) * (x_1(j) - x_2(j)) .gt. 0.0_rp)
then
256 asy_factor = this%asyincr
261 low(j) = x(j) - asy_factor * (x_1(j) - low(j))
262 upp(j) = x(j) + asy_factor * (upp(j) - x_1(j))
268 low = max(low, x - 10.0_rp * x_diff)
269 low = min(low, x - 0.01_rp * x_diff)
271 upp = min(upp, x + 10.0_rp * x_diff)
272 upp = max(upp, x + 0.01_rp * x_diff)
286 associate(alpha => this%alpha%x, beta => this%beta%x, &
287 xmin => this%xmin%x, xmax => this%xmax%x, &
288 low => this%low%x, upp => this%upp%x, x => x)
290 alpha = max(xmin, low + 0.1_rp*(x - low), x - 0.5_rp*x_diff)
291 beta = min(xmax, upp - 0.1_rp*(upp - x), x + 0.5_rp*x_diff)
298 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
299 pij => this%pij%x, qij => this%qij%x, &
300 low => this%low%x, upp => this%upp%x)
303 1.001_rp * max(df0dx, 0.0_rp) &
304 + 0.001_rp * max(-df0dx, 0.0_rp) &
305 + 0.00001_rp / max(x_diff, 0.00001_rp) &
309 0.001_rp * max(df0dx, 0.0_rp) &
310 + 1.001_rp * max(-df0dx, 0.0_rp) &
311 + 0.00001_rp / max(x_diff, 0.00001_rp)&
317 1.001_rp * max(dfdx(i, j), 0.0_rp) &
318 + 0.001_rp * max(-dfdx(i, j), 0.0_rp) &
319 + 0.00001_rp / max(x_diff(j), 0.00001_rp) &
320 ) * (upp(j) - x(j))**2
323 0.001_rp * max(dfdx(i, j), 0.0_rp) &
324 + 1.001_rp * max(-dfdx(i, j), 0.0_rp) &
325 + 0.00001_rp / max(x_diff(j), 0.00001_rp) &
326 ) * (x(j) - low(j))**2
335 associate(bi => this%bi%x, &
336 pij => this%pij%x, qij => this%qij%x, &
337 low => this%low%x, upp => this%upp%x)
343 + pij(i, j) / (upp(j) - x(j)) &
344 + qij(i, j) / (x(j) - low(j))
348 call mpi_allreduce(mpi_in_place, bi, this%m, &
349 mpi_real_precision, mpi_sum, neko_comm, ierr)
353 end subroutine mma_gensub_cpu
357 subroutine mma_subsolve_dpip_cpu(this, designx)
368 class(mma_t),
intent(inout) :: this
369 real(kind=rp),
dimension(this%n),
intent(inout) :: designx
372 integer :: i, j, k, iter, itto, ierr
373 real(kind=rp) :: epsi, residual_max, residual_norm, &
374 z, zeta, rez, rezeta, &
376 steg, zold, zetaold, new_residual
377 real(kind=rp),
dimension(this%m) :: y, lambda, s, mu, &
378 rey, relambda, remu, res, &
380 dy, dlambda, ds, dmu, &
381 yold, lambdaold, sold, muold
382 real(kind=rp),
dimension(this%n) :: x, xsi, eta, &
384 delx, diagx, dx, dxsi, deta, &
386 real(kind=rp),
dimension(4*this%m + 2) :: residual_small
387 real(kind=rp),
dimension(3*this%n + 4*this%m + 2) :: residual
388 real(kind=rp),
dimension(2*this%n + 4*this%m + 2) :: xx, dxx
390 real(kind=rp),
dimension(this%m, this%n) :: gg
391 real(kind=rp),
dimension(this%m+1) :: bb
392 real(kind=rp),
dimension(this%m+1, this%m+1) :: aa
393 real(kind=rp),
dimension(this%m * this%m) :: aa_buffer
398 integer,
dimension(this%m+1) :: ipiv
401 real(kind=rp) :: re_sq_norm
402 real(kind=rp) :: minimal_epsilon
411 x = 0.5_rp * (this%alpha%x + this%beta%x)
417 xsi = max(1.0_rp, 1.0_rp / (x - this%alpha%x))
418 eta = max(1.0_rp, 1.0_rp / (this%beta%x - x))
419 mu = max(1.0_rp, 0.5_rp * this%c%x)
421 call mpi_allreduce(this%n, nglobal, 1, &
422 mpi_integer, mpi_sum, neko_comm, ierr)
427 minimal_epsilon = max(0.9_rp * this%epsimin, 1.0e-12_rp)
428 call mpi_allreduce(mpi_in_place, minimal_epsilon, 1, &
429 mpi_real_precision, mpi_min, neko_comm, ierr)
434 do while (epsi .gt. minimal_epsilon)
441 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
442 pij => this%pij%x, qij => this%qij%x, &
443 low => this%low%x, upp => this%upp%x, &
444 alpha => this%alpha%x, beta => this%beta%x, &
445 c => this%c%x, d => this%d%x, &
446 a0 => this%a0, a => this%a%x, &
449 rex = (p0j + matmul(transpose(pij), lambda)) / (upp - x)**2 &
450 - (q0j + matmul(transpose(qij), lambda)) / (x - low)**2 &
453 rey = c + d * y - lambda - mu
454 rez = a0 - zeta - dot_product(lambda, a)
460 relambda(i) = relambda(i) &
461 + pij(i, j) / (upp(j) - x(j)) &
462 + qij(i, j) / (x(j) - low(j))
472 call mpi_allreduce(mpi_in_place, relambda, this%m, &
473 mpi_real_precision, mpi_sum, neko_comm, ierr)
474 relambda = relambda - this%a%x*z - y + s - this%bi%x
476 rexsi = xsi * (x - this%alpha%x) - epsi
477 reeta = eta * (this%beta%x - x) - epsi
479 rezeta = zeta * z - epsi
480 res = lambda * s - epsi
483 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
484 residual_small = [rey, rez, relambda, remu, rezeta, res]
486 residual_max = maxval(abs(residual))
487 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
489 call mpi_allreduce(mpi_in_place, residual_max, 1, &
490 mpi_real_precision, mpi_max, neko_comm, ierr)
492 call mpi_allreduce(mpi_in_place, re_sq_norm, &
493 1, mpi_real_precision, mpi_sum, neko_comm, ierr)
495 residual_norm = sqrt(norm2(residual_small)**2 + re_sq_norm)
500 do iter = 1, this%max_iter
503 if (residual_max .lt. epsi)
exit
509 + this%pij%x(i,j) * lambda(i) / (this%upp%x(j) - x(j))**2 &
510 - this%qij%x(i,j) * lambda(i) / (x(j) - this%low%x(j))**2
515 + this%p0j%x / (this%upp%x - x)**2 &
516 - this%q0j%x / (x - this%low%x)**2 &
517 - epsi / (x - this%alpha%x) &
518 + epsi / (this%beta%x - x)
520 dely = this%c%x + this%d%x * y - lambda - epsi / y
521 delz = this%a0 - dot_product(lambda, this%a%x) - epsi / z
527 dellambda(i) = dellambda(i) &
528 + this%pij%x(i, j) / (this%upp%x(j) - x(j)) &
529 + this%qij%x(i, j) / (x(j) - this%low%x(j))
533 call mpi_allreduce(mpi_in_place, dellambda, this%m, &
534 mpi_real_precision, mpi_sum, neko_comm, ierr)
536 dellambda = dellambda - this%a%x*z - y - this%bi%x + epsi / lambda
539 gg(i,:) = this%pij%x(i,:) / (this%upp%x - x)**2 &
540 - this%qij%x(i,:) / (x - this%low%x)**2
544 (this%p0j%x + matmul(transpose(this%pij%x), lambda)) &
545 / (this%upp%x - x)**3 &
546 + (this%q0j%x + matmul(transpose(this%qij%x), lambda)) &
547 / (x - this%low%x)**3
549 diagx = 2.0_rp * diagx &
550 + xsi / (x - this%alpha%x) &
551 + eta / (this%beta%x - x)
565 bb(i) = bb(i) + gg(i, j) * (delx(j) / diagx(j))
569 call mpi_allreduce(mpi_in_place, bb, this%m, &
570 mpi_real_precision, mpi_sum, neko_comm, ierr)
572 bb(1:this%m) = dellambda + dely / (this%d%x + mu / y) - bb(1:this%m)
573 bb(this%m + 1) = delz
590 aa(i, j) = aa(i, j) &
591 + gg(i, k) * (1.0_rp / diagx(k)) * gg(j, k)
596 aa_buffer = reshape(aa(1:this%m, 1:this%m), [this%m * this%m])
598 call mpi_allreduce(mpi_in_place, aa_buffer, &
599 this%m*this%m, mpi_real_precision, mpi_sum, neko_comm, ierr)
601 aa(1:this%m, 1:this%m) = reshape(aa_buffer, [this%m, this%m])
605 aa(i, i) = aa(i, i) &
607 + 1.0_rp / (this%d%x(i) + mu(i) / y(i))
610 aa(1:this%m, this%m+1) = this%a%x
611 aa(this%m+1, 1:this%m) = this%a%x
612 aa(this%m+1, this%m+1) = - zeta/z
614 call dgesv(this%m + 1, 1, aa, this%m + 1, ipiv, bb, this%m + 1, info)
616 if (info .ne. 0)
then
617 call neko_error(
"DGESV failed to solve the linear system in " // &
618 "mma_subsolve_dpip.")
622 dlambda = bb(1:this%m)
626 dx = - delx / diagx - matmul(transpose(gg), dlambda) / diagx
627 dy = (-dely + dlambda) / (this%d%x + mu / y)
629 dxsi = -xsi + (epsi - dx * xsi) / (x - this%alpha%x)
630 deta = -eta + (epsi + dx * eta) / (this%beta%x - x)
631 dmu = -mu + (epsi - mu * dy) / y
632 dzeta = -zeta + (epsi - zeta * dz) / z
633 ds = -s + (epsi - dlambda * s) / lambda
635 dxx = [dy, dz, dlambda, dxsi, deta, dmu, dzeta, ds]
636 xx = [y, z, lambda, xsi, eta, mu, zeta, s]
638 steg = 1.0_rp / maxval([ &
640 -1.01_rp * dxx / xx, &
641 -1.01_rp * dx / (x - this%alpha%x), &
642 1.01_rp * dx / (this%beta%x - x) &
656 new_residual = 2.0_rp * residual_norm
659 call mpi_allreduce(mpi_in_place, steg, 1, &
660 mpi_real_precision, mpi_min, neko_comm, ierr)
661 call mpi_allreduce(mpi_in_place, new_residual, 1, &
662 mpi_real_precision, mpi_min, neko_comm, ierr)
667 do while ((new_residual .gt. residual_norm) .and. (itto .lt. 50))
675 lambda = lambdaold + steg*dlambda
676 xsi = xsiold + steg*dxsi
677 eta = etaold + steg*deta
678 mu = muold + steg*dmu
679 zeta = zetaold + steg*dzeta
684 rex = (this%p0j%x + matmul(transpose(this%pij%x), lambda)) &
685 / (this%upp%x - x)**2 &
686 - (this%q0j%x + matmul(transpose(this%qij%x), lambda)) &
687 / (x - this%low%x)**2 &
690 rey = this%c%x + this%d%x*y - lambda - mu
691 rez = this%a0 - zeta - dot_product(lambda, this%a%x)
697 relambda(i) = relambda(i) &
698 + this%pij%x(i, j) / (this%upp%x(j) - x(j)) &
699 + this%qij%x(i, j) / (x(j) - this%low%x(j))
703 call mpi_allreduce(mpi_in_place, relambda, this%m, &
704 mpi_real_precision, mpi_sum, neko_comm, ierr)
706 relambda = relambda - this%a%x*z - y + s - this%bi%x
708 rexsi = xsi * (x - this%alpha%x) - epsi
709 reeta = eta * (this%beta%x - x) - epsi
711 rezeta = zeta * z - epsi
712 res = lambda * s - epsi
715 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
716 call mpi_allreduce(mpi_in_place, re_sq_norm, &
717 1, mpi_real_precision, mpi_sum, neko_comm, ierr)
719 residual_small = [rey, rez, relambda, remu, rezeta, res]
720 new_residual = sqrt(norm2(residual_small)**2 + re_sq_norm)
726 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
729 residual_norm = new_residual
730 residual_max = maxval(abs(residual))
731 call mpi_allreduce(mpi_in_place, residual_max, 1, &
732 mpi_real_precision, mpi_max, neko_comm, ierr)
739 this%xold2%x = this%xold1%x
740 this%xold1%x = designx
746 this%lambda%x = lambda
753 end subroutine mma_subsolve_dpip_cpu
757 subroutine mma_subsolve_dip_cpu(this, designx)
792 class(mma_t),
intent(inout) :: this
793 real(kind=rp),
dimension(this%n),
intent(inout) :: designx
796 integer :: i, j, k, iter, ierr
797 real(kind=rp) :: epsi, residual_max, z, steg
798 real(kind=rp),
dimension(this%m) :: y, lambda, mu, &
799 relambda, remu, dlambda, dmu, gradlambda
800 real(kind=rp),
dimension(this%n) :: x, pjlambda, qjlambda
806 real(kind=rp),
dimension(this%n) :: ljjxinv
807 real(kind=rp),
dimension(this%m,this%n) :: hijx
808 real(kind=rp),
dimension(this%m,this%m) :: hess
809 real(kind=rp) :: hesstrace
815 integer,
dimension(this%m+1) :: ipiv
818 real(kind=rp) :: minimal_epsilon
830 lambda = max(1.0_rp, 0.5_rp * this%c%x)
835 call mpi_allreduce(this%n, nglobal, 1, &
836 mpi_integer, mpi_sum, neko_comm, ierr)
841 minimal_epsilon = max(0.9_rp * this%epsimin, 1.0e-12_rp)
842 call mpi_allreduce(mpi_in_place, minimal_epsilon, 1, &
843 mpi_real_precision, mpi_min, neko_comm, ierr)
848 do while (epsi .gt. minimal_epsilon)
855 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
856 pij => this%pij%x, qij => this%qij%x, &
857 low => this%low%x, upp => this%upp%x, &
858 alpha => this%alpha%x, beta => this%beta%x, &
859 c => this%c%x, d => this%d%x, &
860 a0 => this%a0, a => this%a%x, &
869 if (abs(d(i)) < neko_eps)
then
871 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (1.0e-8_rp))
874 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (d(i)))
882 z = merge(0.0_rp, 1.0_rp, a0 - dot_product(lambda, a) >= 0.0_rp)
888 pjlambda = (p0j + matmul(transpose(pij), lambda))
889 qjlambda = (q0j + matmul(transpose(qij), lambda))
890 x = (sqrt(pjlambda) * low + sqrt(qjlambda) * upp) / &
891 (sqrt(pjlambda) + sqrt(qjlambda))
894 x = merge(alpha, x, x .lt. alpha)
895 x = merge(beta, x, x .gt. beta)
898 relambda = matmul(pij, 1.0_rp / (upp - x)) + &
899 matmul(qij, 1.0_rp / (x - low))
902 call mpi_allreduce(mpi_in_place, relambda, this%m, &
903 mpi_real_precision, mpi_sum, neko_comm, ierr)
904 relambda = relambda - bi - y - a * z + mu
907 remu = mu * lambda - epsi
909 residual_max = maxval(abs([relambda, remu]))
913 do iter = 1, this%max_iter
916 if (residual_max .lt. epsi)
exit
920 gradlambda = matmul(pij, 1.0_rp / (upp - x)) + &
921 matmul(qij, 1.0_rp/(x - low))
924 call mpi_allreduce(mpi_in_place, gradlambda, this%m, &
925 mpi_real_precision, mpi_sum, neko_comm, ierr)
926 gradlambda = gradlambda - bi - y - a * z
929 gradlambda = - gradlambda - epsi / lambda
935 ljjxinv= - 1.0_rp / ( (2.0_rp * pjlambda/(upp - x)**3) + &
936 (2.0_rp * qjlambda/(x - low)**3))
940 ljjxinv = merge(0.0_rp, ljjxinv, x - alpha < neko_eps)
941 ljjxinv = merge(0.0_rp, ljjxinv, beta - x < neko_eps)
944 hijx(i,:) = pij(i,:) / (upp - x)**2 &
945 - qij(i,:) / (x - low)**2
955 hess(i, j) = hess(i, j) &
956 + hijx(i, k) * (ljjxinv(k)) * hijx(j, k)
961 call mpi_allreduce(mpi_in_place, hess, &
962 this%m*this%m, mpi_real_precision, mpi_sum, neko_comm, ierr)
973 if (y(i) .gt. 0.0_rp)
then
974 if (abs(d(i)) < neko_eps)
then
977 hess(i, i) = hess(i, i) - 1.0_rp/d(i)
981 hess(i, i) = hess(i, i) - mu(i) / lambda(i)
988 hesstrace = hesstrace + hess(i, i)
991 hess(i,i) = hess(i, i) - &
992 max(-1.0e-4_rp*hesstrace/this%m, 1.0e-7_rp)
995 call dgesv(this%m , 1, hess, this%m , ipiv, &
996 gradlambda, this%m, info)
998 if (info .ne. 0)
then
999 call neko_error(
"DGESV failed to solve the linear system in " // &
1000 "mma_subsolve_dip.")
1002 dlambda = gradlambda
1005 dmu = -mu + epsi / lambda - dlambda * mu / lambda
1011 steg = merge(-1.01_rp * dlambda(i) / lambda(i), steg, &
1012 steg < -1.01_rp * dlambda(i) / lambda(i))
1013 steg = merge(-1.01_rp * dmu(i) / mu(i), &
1014 steg, steg < -1.01_rp * dmu(i) / mu(i))
1017 steg = 1.0_rp / steg
1019 lambda = lambda + steg*dlambda
1029 if (abs(d(i)) < neko_eps)
then
1031 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (1.0e-8_rp))
1034 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (d(i)))
1042 z = merge(0.0_rp, 1.0_rp, a0 - dot_product(lambda, a) >= 0.0_rp)
1048 pjlambda = (p0j + matmul(transpose(pij), lambda))
1049 qjlambda = (q0j + matmul(transpose(qij), lambda))
1050 x = (sqrt(pjlambda) * low + sqrt(qjlambda) * upp) / &
1051 (sqrt(pjlambda) + sqrt(qjlambda))
1054 x = merge(alpha, x, x .lt. alpha)
1055 x = merge(beta, x, x .gt. beta)
1058 relambda = matmul(pij, 1.0_rp / (upp - x)) + &
1059 matmul(qij, 1.0_rp / (x - low))
1061 call mpi_allreduce(mpi_in_place, relambda, this%m, &
1062 mpi_real_precision, mpi_sum, neko_comm, ierr)
1063 relambda = relambda - bi - y - a * z + mu
1066 remu = mu * lambda - epsi
1068 residual_max = maxval(abs([relambda, remu]))
1072 epsi = 0.1_rp * epsi
1076 this%xold2%x = this%xold1%x
1077 this%xold1%x = designx
1084 this%lambda%x = lambda
1086 end subroutine mma_subsolve_dip_cpu
1088end submodule mma_cpu