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
42 module subroutine mma_update_cpu(this, iter, x, df0dx, fval, dfdx)
50 class(mma_t),
intent(inout) :: this
51 integer,
intent(in) :: iter
52 real(kind=rp),
dimension(this%n),
intent(inout) :: x
53 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
54 real(kind=rp),
dimension(this%m),
intent(in) :: fval
55 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
57 if (.not. this%is_initialized)
then
58 call neko_error(
"The MMA object is not initialized.")
62 call mma_gensub_cpu(this, iter, x, df0dx, fval, dfdx)
65 if (this%subsolver .eq.
"dip")
then
66 call mma_subsolve_dip_cpu(this, x)
68 call mma_subsolve_dpip_cpu(this, x)
71 this%is_updated = .true.
72 end subroutine mma_update_cpu
75 module subroutine mma_kkt_cpu(this, x, df0dx, fval, dfdx)
95 class(mma_t),
intent(inout) :: this
96 real(kind=rp),
dimension(this%n),
intent(in) :: x
97 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
98 real(kind=rp),
dimension(this%m),
intent(in) :: fval
99 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
101 if (this%subsolver .eq.
"dip")
then
102 call mma_dip_kkt_cpu(this, x, df0dx, fval, dfdx)
104 call mma_dpip_kkt_cpu(this, x, df0dx, fval, dfdx)
106 end subroutine mma_kkt_cpu
110 module subroutine mma_dpip_kkt_cpu(this, x, df0dx, fval, dfdx)
130 class(mma_t),
intent(inout) :: this
131 real(kind=rp),
dimension(this%n),
intent(in) :: x
132 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
133 real(kind=rp),
dimension(this%m),
intent(in) :: fval
134 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
136 real(kind=rp) :: rez, rezeta
137 real(kind=rp),
dimension(this%m) :: rey, relambda, remu, res
138 real(kind=rp),
dimension(this%n) :: rex, rexsi, reeta
139 real(kind=rp),
dimension(3*this%n+4*this%m+2) :: residual
141 real(kind=rp),
dimension(4*this%m+2) :: residual_small
143 real(kind=rp) :: re_sq_norm
145 rex = df0dx + matmul(transpose(dfdx), this%lambda%x) &
146 - this%xsi%x + this%eta%x
147 rey = this%c%x + this%d%x*this%y%x - this%lambda%x - this%mu%x
148 rez = this%a0 - this%zeta - dot_product(this%lambda%x, this%a%x)
150 relambda = fval - this%a%x * this%z - this%y%x + this%s%x
151 rexsi = this%xsi%x * (x - this%xmin%x)
152 reeta = this%eta%x * (this%xmax%x - x)
153 remu = this%mu%x * this%y%x
154 rezeta = this%zeta * this%z
155 res = this%lambda%x * this%s%x
157 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
158 residual_small = [rey, rez, relambda, remu, rezeta, res]
160 this%residumax = maxval(abs(residual))
161 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
163 call mpi_allreduce(mpi_in_place, this%residumax, 1, &
164 mpi_real_precision, mpi_max, neko_comm, ierr)
166 call mpi_allreduce(mpi_in_place, re_sq_norm, 1, &
167 mpi_real_precision, mpi_sum, neko_comm, ierr)
169 this%residunorm = sqrt(norm2(residual_small)**2 + re_sq_norm)
170 end subroutine mma_dpip_kkt_cpu
174 module subroutine mma_dip_kkt_cpu(this, x, df0dx, fval, dfdx)
194 class(mma_t),
intent(inout) :: this
195 real(kind=rp),
dimension(this%n),
intent(in) :: x
196 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
197 real(kind=rp),
dimension(this%m),
intent(in) :: fval
198 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
200 real(kind=rp),
dimension(this%m) :: relambda, remu
201 real(kind=rp),
dimension(2*this%m) :: residual
204 relambda = fval - this%a%x * this%z - this%y%x + this%mu%x
206 remu = this%lambda%x * this%mu%x
208 residual = abs([relambda, remu])
209 this%residumax = maxval(residual)
210 this%residunorm = norm2(residual)
212 end subroutine mma_dip_kkt_cpu
218 subroutine mma_gensub_cpu(this, iter, x, df0dx, fval, dfdx)
224 class(mma_t),
intent(inout) :: this
225 real(kind=rp),
dimension(this%n),
intent(in) :: x
226 real(kind=rp),
dimension(this%n),
intent(in) :: df0dx
227 real(kind=rp),
dimension(this%m),
intent(in) :: fval
228 real(kind=rp),
dimension(this%m, this%n),
intent(in) :: dfdx
229 integer,
intent(in) :: iter
230 integer :: i, j, ierr
231 real(kind=rp),
dimension(this%n) :: x_diff
232 real(kind=rp) :: asy_factor
234 x_diff = this%xmax%x - this%xmin%x
238 associate(low => this%low%x, upp => this%upp%x, &
239 x_1 => this%xold1%x, x_2 => this%xold2%x)
241 if (iter .lt. 3)
then
243 low = x - this%asyinit * x_diff
244 upp = x + this%asyinit * x_diff
247 if ((x(j) - x_1(j)) * (x_1(j) - x_2(j)) .lt. 0.0_rp)
then
248 asy_factor = this%asydecr
249 else if ((x(j) - x_1(j)) * (x_1(j) - x_2(j)) .gt. 0.0_rp)
then
250 asy_factor = this%asyincr
255 low(j) = x(j) - asy_factor * (x_1(j) - low(j))
256 upp(j) = x(j) + asy_factor * (upp(j) - x_1(j))
262 low = max(low, x - 10.0_rp * x_diff)
263 low = min(low, x - 0.01_rp * x_diff)
265 upp = min(upp, x + 10.0_rp * x_diff)
266 upp = max(upp, x + 0.01_rp * x_diff)
280 associate(alpha => this%alpha%x, beta => this%beta%x, &
281 xmin => this%xmin%x, xmax => this%xmax%x, &
282 low => this%low%x, upp => this%upp%x, x => x)
284 alpha = max(xmin, low + 0.1_rp*(x - low), x - 0.5_rp*x_diff)
285 beta = min(xmax, upp - 0.1_rp*(upp - x), x + 0.5_rp*x_diff)
292 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
293 pij => this%pij%x, qij => this%qij%x, &
294 low => this%low%x, upp => this%upp%x)
297 1.001_rp * max(df0dx, 0.0_rp) &
298 + 0.001_rp * max(-df0dx, 0.0_rp) &
299 + 0.00001_rp / max(x_diff, 0.00001_rp) &
303 0.001_rp * max(df0dx, 0.0_rp) &
304 + 1.001_rp * max(-df0dx, 0.0_rp) &
305 + 0.00001_rp / max(x_diff, 0.00001_rp)&
311 1.001_rp * max(dfdx(i, j), 0.0_rp) &
312 + 0.001_rp * max(-dfdx(i, j), 0.0_rp) &
313 + 0.00001_rp / max(x_diff(j), 0.00001_rp) &
314 ) * (upp(j) - x(j))**2
317 0.001_rp * max(dfdx(i, j), 0.0_rp) &
318 + 1.001_rp * max(-dfdx(i, j), 0.0_rp) &
319 + 0.00001_rp / max(x_diff(j), 0.00001_rp) &
320 ) * (x(j) - low(j))**2
329 associate(bi => this%bi%x, &
330 pij => this%pij%x, qij => this%qij%x, &
331 low => this%low%x, upp => this%upp%x)
337 + pij(i, j) / (upp(j) - x(j)) &
338 + qij(i, j) / (x(j) - low(j))
342 call mpi_allreduce(mpi_in_place, bi, this%m, &
343 mpi_real_precision, mpi_sum, neko_comm, ierr)
347 end subroutine mma_gensub_cpu
351 subroutine mma_subsolve_dpip_cpu(this, designx)
362 class(mma_t),
intent(inout) :: this
363 real(kind=rp),
dimension(this%n),
intent(inout) :: designx
366 integer :: i, j, k, iter, itto, ierr
367 real(kind=rp) :: epsi, residual_max, residual_norm, &
368 z, zeta, rez, rezeta, &
370 steg, zold, zetaold, new_residual
371 real(kind=rp),
dimension(this%m) :: y, lambda, s, mu, &
372 rey, relambda, remu, res, &
374 dy, dlambda, ds, dmu, &
375 yold, lambdaold, sold, muold
376 real(kind=rp),
dimension(this%n) :: x, xsi, eta, &
378 delx, diagx, dx, dxsi, deta, &
380 real(kind=rp),
dimension(4*this%m + 2) :: residual_small
381 real(kind=rp),
dimension(3*this%n + 4*this%m + 2) :: residual
382 real(kind=rp),
dimension(2*this%n + 4*this%m + 2) :: xx, dxx
384 real(kind=rp),
dimension(this%m, this%n) :: gg
385 real(kind=rp),
dimension(this%m+1) :: bb
386 real(kind=rp),
dimension(this%m+1, this%m+1) :: aa
387 real(kind=rp),
dimension(this%m * this%m) :: aa_buffer
392 integer,
dimension(this%m+1) :: ipiv
395 real(kind=rp) :: re_sq_norm
396 real(kind=rp) :: minimal_epsilon
405 x = 0.5_rp * (this%alpha%x + this%beta%x)
411 xsi = max(1.0_rp, 1.0_rp / (x - this%alpha%x))
412 eta = max(1.0_rp, 1.0_rp / (this%beta%x - x))
413 mu = max(1.0_rp, 0.5_rp * this%c%x)
415 call mpi_allreduce(this%n, nglobal, 1, &
416 mpi_integer, mpi_sum, neko_comm, ierr)
421 minimal_epsilon = max(0.9_rp * this%epsimin, 1.0e-12_rp)
422 call mpi_allreduce(mpi_in_place, minimal_epsilon, 1, &
423 mpi_real_precision, mpi_min, neko_comm, ierr)
428 do while (epsi .gt. minimal_epsilon)
435 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
436 pij => this%pij%x, qij => this%qij%x, &
437 low => this%low%x, upp => this%upp%x, &
438 alpha => this%alpha%x, beta => this%beta%x, &
439 c => this%c%x, d => this%d%x, &
440 a0 => this%a0, a => this%a%x, &
443 rex = (p0j + matmul(transpose(pij), lambda)) / (upp - x)**2 &
444 - (q0j + matmul(transpose(qij), lambda)) / (x - low)**2 &
447 rey = c + d * y - lambda - mu
448 rez = a0 - zeta - dot_product(lambda, a)
454 relambda(i) = relambda(i) &
455 + pij(i, j) / (upp(j) - x(j)) &
456 + qij(i, j) / (x(j) - low(j))
466 call mpi_allreduce(mpi_in_place, relambda, this%m, &
467 mpi_real_precision, mpi_sum, neko_comm, ierr)
468 relambda = relambda - this%a%x*z - y + s - this%bi%x
470 rexsi = xsi * (x - this%alpha%x) - epsi
471 reeta = eta * (this%beta%x - x) - epsi
473 rezeta = zeta * z - epsi
474 res = lambda * s - epsi
477 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
478 residual_small = [rey, rez, relambda, remu, rezeta, res]
480 residual_max = maxval(abs(residual))
481 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
483 call mpi_allreduce(mpi_in_place, residual_max, 1, &
484 mpi_real_precision, mpi_max, neko_comm, ierr)
486 call mpi_allreduce(mpi_in_place, re_sq_norm, &
487 1, mpi_real_precision, mpi_sum, neko_comm, ierr)
489 residual_norm = sqrt(norm2(residual_small)**2 + re_sq_norm)
494 do iter = 1, this%max_iter
497 if (residual_max .lt. epsi)
exit
503 + this%pij%x(i,j) * lambda(i) / (this%upp%x(j) - x(j))**2 &
504 - this%qij%x(i,j) * lambda(i) / (x(j) - this%low%x(j))**2
509 + this%p0j%x / (this%upp%x - x)**2 &
510 - this%q0j%x / (x - this%low%x)**2 &
511 - epsi / (x - this%alpha%x) &
512 + epsi / (this%beta%x - x)
514 dely = this%c%x + this%d%x * y - lambda - epsi / y
515 delz = this%a0 - dot_product(lambda, this%a%x) - epsi / z
521 dellambda(i) = dellambda(i) &
522 + this%pij%x(i, j) / (this%upp%x(j) - x(j)) &
523 + this%qij%x(i, j) / (x(j) - this%low%x(j))
527 call mpi_allreduce(mpi_in_place, dellambda, this%m, &
528 mpi_real_precision, mpi_sum, neko_comm, ierr)
530 dellambda = dellambda - this%a%x*z - y - this%bi%x + epsi / lambda
533 gg(i,:) = this%pij%x(i,:) / (this%upp%x - x)**2 &
534 - this%qij%x(i,:) / (x - this%low%x)**2
538 (this%p0j%x + matmul(transpose(this%pij%x), lambda)) &
539 / (this%upp%x - x)**3 &
540 + (this%q0j%x + matmul(transpose(this%qij%x), lambda)) &
541 / (x - this%low%x)**3
543 diagx = 2.0_rp * diagx &
544 + xsi / (x - this%alpha%x) &
545 + eta / (this%beta%x - x)
559 bb(i) = bb(i) + gg(i, j) * (delx(j) / diagx(j))
563 call mpi_allreduce(mpi_in_place, bb, this%m, &
564 mpi_real_precision, mpi_sum, neko_comm, ierr)
566 bb(1:this%m) = dellambda + dely / (this%d%x + mu / y) - bb(1:this%m)
567 bb(this%m + 1) = delz
584 aa(i, j) = aa(i, j) &
585 + gg(i, k) * (1.0_rp / diagx(k)) * gg(j, k)
590 aa_buffer = reshape(aa(1:this%m, 1:this%m), [this%m * this%m])
592 call mpi_allreduce(mpi_in_place, aa_buffer, &
593 this%m*this%m, mpi_real_precision, mpi_sum, neko_comm, ierr)
595 aa(1:this%m, 1:this%m) = reshape(aa_buffer, [this%m, this%m])
599 aa(i, i) = aa(i, i) &
601 + 1.0_rp / (this%d%x(i) + mu(i) / y(i))
604 aa(1:this%m, this%m+1) = this%a%x
605 aa(this%m+1, 1:this%m) = this%a%x
606 aa(this%m+1, this%m+1) = - zeta/z
608 call dgesv(this%m + 1, 1, aa, this%m + 1, ipiv, bb, this%m + 1, info)
610 if (info .ne. 0)
then
611 call neko_error(
"DGESV failed to solve the linear system in " // &
612 "mma_subsolve_dpip.")
616 dlambda = bb(1:this%m)
620 dx = - delx / diagx - matmul(transpose(gg), dlambda) / diagx
621 dy = (-dely + dlambda) / (this%d%x + mu / y)
623 dxsi = -xsi + (epsi - dx * xsi) / (x - this%alpha%x)
624 deta = -eta + (epsi + dx * eta) / (this%beta%x - x)
625 dmu = -mu + (epsi - mu * dy) / y
626 dzeta = -zeta + (epsi - zeta * dz) / z
627 ds = -s + (epsi - dlambda * s) / lambda
629 dxx = [dy, dz, dlambda, dxsi, deta, dmu, dzeta, ds]
630 xx = [y, z, lambda, xsi, eta, mu, zeta, s]
632 steg = 1.0_rp / maxval([ &
634 -1.01_rp * dxx / xx, &
635 -1.01_rp * dx / (x - this%alpha%x), &
636 1.01_rp * dx / (this%beta%x - x) &
650 new_residual = 2.0_rp * residual_norm
653 call mpi_allreduce(mpi_in_place, steg, 1, &
654 mpi_real_precision, mpi_min, neko_comm, ierr)
655 call mpi_allreduce(mpi_in_place, new_residual, 1, &
656 mpi_real_precision, mpi_min, neko_comm, ierr)
661 do while ((new_residual .gt. residual_norm) .and. (itto .lt. 50))
669 lambda = lambdaold + steg*dlambda
670 xsi = xsiold + steg*dxsi
671 eta = etaold + steg*deta
672 mu = muold + steg*dmu
673 zeta = zetaold + steg*dzeta
678 rex = (this%p0j%x + matmul(transpose(this%pij%x), lambda)) &
679 / (this%upp%x - x)**2 &
680 - (this%q0j%x + matmul(transpose(this%qij%x), lambda)) &
681 / (x - this%low%x)**2 &
684 rey = this%c%x + this%d%x*y - lambda - mu
685 rez = this%a0 - zeta - dot_product(lambda, this%a%x)
691 relambda(i) = relambda(i) &
692 + this%pij%x(i, j) / (this%upp%x(j) - x(j)) &
693 + this%qij%x(i, j) / (x(j) - this%low%x(j))
697 call mpi_allreduce(mpi_in_place, relambda, this%m, &
698 mpi_real_precision, mpi_sum, neko_comm, ierr)
700 relambda = relambda - this%a%x*z - y + s - this%bi%x
702 rexsi = xsi * (x - this%alpha%x) - epsi
703 reeta = eta * (this%beta%x - x) - epsi
705 rezeta = zeta * z - epsi
706 res = lambda * s - epsi
709 re_sq_norm = norm2(rex)**2 + norm2(rexsi)**2 + norm2(reeta)**2
710 call mpi_allreduce(mpi_in_place, re_sq_norm, &
711 1, mpi_real_precision, mpi_sum, neko_comm, ierr)
713 residual_small = [rey, rez, relambda, remu, rezeta, res]
714 new_residual = sqrt(norm2(residual_small)**2 + re_sq_norm)
720 residual = [rex, rey, rez, relambda, rexsi, reeta, remu, rezeta, res]
723 residual_norm = new_residual
724 residual_max = maxval(abs(residual))
725 call mpi_allreduce(mpi_in_place, residual_max, 1, &
726 mpi_real_precision, mpi_max, neko_comm, ierr)
733 this%xold2%x = this%xold1%x
734 this%xold1%x = designx
740 this%lambda%x = lambda
747 end subroutine mma_subsolve_dpip_cpu
751 subroutine mma_subsolve_dip_cpu(this, designx)
786 class(mma_t),
intent(inout) :: this
787 real(kind=rp),
dimension(this%n),
intent(inout) :: designx
790 integer :: i, j, k, iter, ierr
791 real(kind=rp) :: epsi, residual_max, z, steg
792 real(kind=rp),
dimension(this%m) :: y, lambda, mu, &
793 relambda, remu, dlambda, dmu, gradlambda
794 real(kind=rp),
dimension(this%n) :: x, pjlambda, qjlambda
800 real(kind=rp),
dimension(this%n) :: ljjxinv
801 real(kind=rp),
dimension(this%m,this%n) :: hijx
802 real(kind=rp),
dimension(this%m,this%m) :: hess
803 real(kind=rp) :: hesstrace
809 integer,
dimension(this%m+1) :: ipiv
812 real(kind=rp) :: minimal_epsilon
824 lambda = max(1.0_rp, 0.5_rp * this%c%x)
829 call mpi_allreduce(this%n, nglobal, 1, &
830 mpi_integer, mpi_sum, neko_comm, ierr)
835 minimal_epsilon = max(0.9_rp * this%epsimin, 1.0e-12_rp)
836 call mpi_allreduce(mpi_in_place, minimal_epsilon, 1, &
837 mpi_real_precision, mpi_min, neko_comm, ierr)
842 do while (epsi .gt. minimal_epsilon)
849 associate(p0j => this%p0j%x, q0j => this%q0j%x, &
850 pij => this%pij%x, qij => this%qij%x, &
851 low => this%low%x, upp => this%upp%x, &
852 alpha => this%alpha%x, beta => this%beta%x, &
853 c => this%c%x, d => this%d%x, &
854 a0 => this%a0, a => this%a%x, &
863 if (abs(d(i)) < neko_eps)
then
865 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (1.0e-8_rp))
868 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (d(i)))
876 z = merge(0.0_rp, 1.0_rp, a0 - dot_product(lambda, a) >= 0.0_rp)
882 pjlambda = (p0j + matmul(transpose(pij), lambda))
883 qjlambda = (q0j + matmul(transpose(qij), lambda))
884 x = (sqrt(pjlambda) * low + sqrt(qjlambda) * upp) / &
885 (sqrt(pjlambda) + sqrt(qjlambda))
888 x = merge(alpha, x, x .lt. alpha)
889 x = merge(beta, x, x .gt. beta)
892 relambda = matmul(pij, 1.0_rp / (upp - x)) + &
893 matmul(qij, 1.0_rp / (x - low))
896 call mpi_allreduce(mpi_in_place, relambda, this%m, &
897 mpi_real_precision, mpi_sum, neko_comm, ierr)
898 relambda = relambda - bi - y - a * z + mu
901 remu = mu * lambda - epsi
903 residual_max = maxval(abs([relambda, remu]))
907 do iter = 1, this%max_iter
910 if (residual_max .lt. epsi)
exit
914 gradlambda = matmul(pij, 1.0_rp / (upp - x)) + &
915 matmul(qij, 1.0_rp/(x - low))
918 call mpi_allreduce(mpi_in_place, gradlambda, this%m, &
919 mpi_real_precision, mpi_sum, neko_comm, ierr)
920 gradlambda = gradlambda - bi - y - a * z
923 gradlambda = - gradlambda - epsi / lambda
929 ljjxinv= - 1.0_rp / ( (2.0_rp * pjlambda/(upp - x)**3) + &
930 (2.0_rp * qjlambda/(x - low)**3))
934 ljjxinv = merge(0.0_rp, ljjxinv, x - alpha < neko_eps)
935 ljjxinv = merge(0.0_rp, ljjxinv, beta - x < neko_eps)
938 hijx(i,:) = pij(i,:) / (upp - x)**2 &
939 - qij(i,:) / (x - low)**2
949 hess(i, j) = hess(i, j) &
950 + hijx(i, k) * (ljjxinv(k)) * hijx(j, k)
955 call mpi_allreduce(mpi_in_place, hess, &
956 this%m*this%m, mpi_real_precision, mpi_sum, neko_comm, ierr)
967 if (y(i) .gt. 0.0_rp)
then
968 if (abs(d(i)) < neko_eps)
then
971 hess(i, i) = hess(i, i) - 1.0_rp/d(i)
975 hess(i, i) = hess(i, i) - mu(i) / lambda(i)
982 hesstrace = hesstrace + hess(i, i)
985 hess(i,i) = hess(i, i) - &
986 max(-1.0e-4_rp*hesstrace/this%m, 1.0e-7_rp)
989 call dgesv(this%m , 1, hess, this%m , ipiv, &
990 gradlambda, this%m, info)
992 if (info .ne. 0)
then
993 call neko_error(
"DGESV failed to solve the linear system in " // &
999 dmu = -mu + epsi / lambda - dlambda * mu / lambda
1005 steg = merge(-1.01_rp * dlambda(i) / lambda(i), steg, &
1006 steg < -1.01_rp * dlambda(i) / lambda(i))
1007 steg = merge(-1.01_rp * dmu(i) / mu(i), &
1008 steg, steg < -1.01_rp * dmu(i) / mu(i))
1011 steg = 1.0_rp / steg
1013 lambda = lambda + steg*dlambda
1023 if (abs(d(i)) < neko_eps)
then
1025 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (1.0e-8_rp))
1028 y(i) = max(0.0_rp, (lambda(i) - c(i)) / (d(i)))
1036 z = merge(0.0_rp, 1.0_rp, a0 - dot_product(lambda, a) >= 0.0_rp)
1042 pjlambda = (p0j + matmul(transpose(pij), lambda))
1043 qjlambda = (q0j + matmul(transpose(qij), lambda))
1044 x = (sqrt(pjlambda) * low + sqrt(qjlambda) * upp) / &
1045 (sqrt(pjlambda) + sqrt(qjlambda))
1048 x = merge(alpha, x, x .lt. alpha)
1049 x = merge(beta, x, x .gt. beta)
1052 relambda = matmul(pij, 1.0_rp / (upp - x)) + &
1053 matmul(qij, 1.0_rp / (x - low))
1055 call mpi_allreduce(mpi_in_place, relambda, this%m, &
1056 mpi_real_precision, mpi_sum, neko_comm, ierr)
1057 relambda = relambda - bi - y - a * z + mu
1060 remu = mu * lambda - epsi
1062 residual_max = maxval(abs([relambda, remu]))
1066 epsi = 0.1_rp * epsi
1070 this%xold2%x = this%xold1%x
1071 this%xold1%x = designx
1078 this%lambda%x = lambda
1080 end subroutine mma_subsolve_dip_cpu
1082end submodule mma_cpu