Ensure constraints are satisfied
Opened this issue · 3 comments
In the past we found that VMCON was reporting that it had converged but the constraints were not accurately satisfied, although we never understood why. To fix this we added code to ensure that the constraints were satisfied before VMCON exited.
! Check convergence of constraint residuals
summ = 0.0D0
!do i = 1,m
! This only includes the equality constraints Issue #505
do i = 1,meq
summ = summ + conf(i)*conf(i)
end do
sqsumsq = sqrt(summ)
etc
if (verbose == 1) then
write(*,'(a,es13.5,a,es13.5)') &
'Constraint residuals (sqsumsq) = ',sqsumsq, &
' Convergence parameter = ',sum
end if
! Writting the step results in OPT.DAT file
do i = 1, n
delta_var(i) = delta(i)
end do
! Comment in to write optional optimisation information output file
! write(opt_file, '(I5,E28.10,*(E18.10))') niter+1, abs(objf), sum, sqsumsq, conf, x, delta_var
! Exit if both convergence criteria are satisfied
! (the original criterion, plus constraint residuals below the tolerance level)
! Temporarily set the two tolerances equal (should perhaps be an input parameter)
sqsumsq_tol = tol
! Store the lowest valid FoM (ie where constraints are satisfied)
if (sqsumsq < sqsumsq_tol) lowest_valid_fom = min(lowest_valid_fom, objf)
The line that actually checks for convergence:
if ((sum <= tol).and.(sqsumsq < sqsumsq_tol)) then
if (verbose == 1) then
write(*,*) 'Convergence parameter < convergence criterion (epsvmc)'
write(*,*) 'Root of sum of squares of residuals < tolerance (sqsumsq_tol)'
end if
exit_code = 1
return
end if
Proposed solution
It might help to add this additional convergence test to pyvmcon. One could also add a new line to the input code to allow sqsumsq_tol
and tol
to be input separately.
@jonmaddock @timothy-nunn
Just as an example, in the large tokamak regression test the constraint residuals are five orders of magnitude larger than the convergence parameter:
Square root of the sum of squares of the constraint residuals (sqsumsq) 5.639E-05 OP
VMCON convergence parameter (convergence_parameter) 5.589E-10 OP
In this run the error tolerance for VMCON is epsvmc = 1e-7
.
The convergence parameter is given in the Crane report:
The constraint residuals are
It would be good to output a table of all the terms in the convergence equation in a separate csv
file.
Separate issues
This is related to my work on ensuring that the inequality constraints are completely satisfied (zero tolerance), whilst the equality constraints are allowed some tolerance (as in the current convergence criterion). The PR for this will be created shortly on the PyVMCON
repository, as it is required for reliability analysis work. In my view, this should be merged separately.
The optional output of all terms in a .csv
file is a good idea, and could also be handled separately.
However, the main point in this issue as I understand it is the possibility that a solution may be "converged" according to the original convergence criterion whilst having significantly large equality constraint residuals (as Michael reports above, "five orders of magnitude difference"). This is due to the Lagrange multipliers
Small Lagrange multipliers
At the solution, the Lagrange multipliers
where
In the convergence criterion,
So, a small
Effect of original convergence criterion
Using sqsumsq
and a small convergence_parameter
; the (large) violated constraints have little effect (small Lagrange multipliers) on the objective function, so the solution is allowed to converge despite the large residuals.
Potential drawback
Whilst I think this is clever, if I'm not mistaken I think there is a drawback to this approach:
instead, but I fear this is unnecessary.
Michael, forgive me if I've just caught up with you.
Possible solution
Taking on board Michael's original suggestion of a separate sqsumsq_tol
(or alternative equality constraint tolerance), I wonder if it might be worth dropping the Lagrange multipliers altogether in the convergence criterion, and simply using sqsumsq < sqsumsq_tol
instead. However, the Lagrange multiplier do help guard against the opposite situation where a slightly violated constraint sqsumsq < sqsumsq_tol
test if it were the only requirement in the convergence criterion.
I therefore agree with Michael that an equality constraint tolerance (perhaps for each equality constraint individually, as per other solvers) should be added to the existing convergence criterion to ensure a certain level of equality constraint residuals is respected, irrespective of the Lagrange multipliers. This would also address the problem in the "potential drawback" section too, I believe.
Summary
- Add a zero-tolerance inequality constraint check to the convergence criterion
- Write out solution variables in
.csv
- Add a specific equality tolerance to the convergence criterion
Sounds good. I would advise doing the zero-tolerance inequality check and the equality constraint check separately and testing each time since I have no idea what the zero-tolerance inequality check will do.