Record coupled correction benefit cost and nonlinear curvature limits
This commit is contained in:
@@ -26,6 +26,47 @@ def near_vector(a,b,scale):
|
||||
return len(a)==len(b) and norm(minus(a,b)) <= 1024*EPS*max(scale,1.e-28)
|
||||
|
||||
|
||||
def finite_ratio(numerator,denominator):
|
||||
if not math.isfinite(numerator) or not math.isfinite(denominator) or denominator==0:
|
||||
return None
|
||||
result=numerator/denominator
|
||||
return result if math.isfinite(result) else None
|
||||
|
||||
|
||||
def correction_mechanism(base,direction,alpha,prediction,before_residual,corrected_state,
|
||||
corrected_residual,correction,rhs,action):
|
||||
"""Describe a saved correction; large remainders are observations, not failed audits.
|
||||
|
||||
The candidate Jacobian action gives R_new = (J_candidate c - rhs) + E,
|
||||
where E is the correction's own Taylor remainder. Improving merit does not
|
||||
imply that either term or the affine-target remainder becomes smaller.
|
||||
"""
|
||||
cn,pn,rn=norm(correction),norm(direction),norm(rhs)
|
||||
displacement=minus(corrected_state,base)
|
||||
before=minus(before_residual,prediction)
|
||||
after=minus(corrected_residual,prediction)
|
||||
defect=minus(action,rhs)
|
||||
own_taylor=minus(minus(corrected_residual,before_residual),action)
|
||||
en,dn=norm(own_taylor),norm(defect)
|
||||
reconstruction=[v+w for v,w in zip(defect,own_taylor)]
|
||||
return sanitize({
|
||||
'correction_direction_cosine':finite_ratio(dot(correction,direction),cn*pn),
|
||||
'correction_over_rhs_norm':finite_ratio(cn,rn),
|
||||
'correction_over_alpha_squared':finite_ratio(cn,alpha*alpha),
|
||||
'corrected_displacement_norm':norm(displacement),
|
||||
'corrected_displacement_over_outer_step_norm':finite_ratio(norm(displacement),alpha*pn),
|
||||
'effective_direction_projection_t':finite_ratio(dot(displacement,direction),pn*pn),
|
||||
'remainder_before_norm':norm(before),
|
||||
'remainder_after_norm':norm(after),
|
||||
'verified_linear_defect_norm':dn,
|
||||
'own_taylor_remainder_norm':en,
|
||||
'own_taylor_over_correction_squared':finite_ratio(en,cn*cn),
|
||||
'own_taylor_over_verified_defect':finite_ratio(en,dn),
|
||||
'linear_defect_dot_own_taylor':dot(defect,own_taylor),
|
||||
'remainder_decomposition_error_norm':norm(minus(after,reconstruction)),
|
||||
'scope':'Saved candidate-J vector algebra; normalized coefficient norms, with no new FEM action or asymptotic-order claim.'})
|
||||
|
||||
|
||||
def inspect_case(folder):
|
||||
try:
|
||||
return inspect_case_artifacts(Path(folder))
|
||||
@@ -270,6 +311,9 @@ def inspect_case_artifacts(folder):
|
||||
'correction_norm':float(row['correction_norm']),'correction_cap':float(row['correction_cap']),
|
||||
'auxiliary_iterations':int(row['aux_iterations']),'auxiliary_verified_defect_norm':float(row['aux_verified_true_norm']),
|
||||
'corrected_affine_target_defect_norm':norm(minus(vectors['corrected'][1],prediction)) if flags['corrected_metric_observed'] else None,
|
||||
'correction_mechanism':correction_mechanism(x,p,a,prediction,vectors['before'][1],vectors['corrected'][0],
|
||||
vectors['corrected'][1],correction,rhs,action) if attempted and flags['corrected_metric_observed'] and
|
||||
correction is not None and rhs is not None and action is not None else None,
|
||||
'auxiliary_seconds':{k:float(row['soc_'+k]) for k in ('refresh_seconds','solve_seconds','verification_seconds','preparation_seconds')},
|
||||
'residual_norms_by_block':{stage:{block:norm(value[1][start:start+n]) for block,(start,n) in rl.items()}
|
||||
for stage,value in vectors.items()}})
|
||||
|
||||
Reference in New Issue
Block a user