@@ -192,6 +192,7 @@ function _buildCalcFactor(
192192 smpid,
193193 varParams,
194194 activehypo,
195+ _slack = nothing ,
195196)
196197 #
197198 # FIXME , make thread safe (cache)
@@ -210,6 +211,7 @@ function _buildCalcFactor(
210211 solveforidx, # solvefor
211212 getManifold (ccwl), # manifold
212213 ccwl. measurement,
214+ _slack,
213215 )
214216end
215217
@@ -391,10 +393,11 @@ function (cf::CalcFactorNormSq)(::Type{CalcConv}, x)
391393 varValsHypo[cf. solvefor][sampleIdx] = x
392394
393395 res = cf (cf. measurement[sampleIdx], map (vvh -> _getindex_anyn (vvh, sampleIdx), varValsHypo)... )
396+ res = isnothing (cf. slack) ? res : res .- cf. slack
394397 return sum (x-> x^ 2 , res)
395398end
396399
397- function _buildHypoCalcFactor (ccwl:: CommonConvWrapper , smpid:: Integer )
400+ function _buildHypoCalcFactor (ccwl:: CommonConvWrapper , smpid:: Integer , _slack )
398401 # build a view to the decision variable memory
399402 varValsHypo = ccwl. varValsAll[][ccwl. hyporecipe. activehypo]
400403 # create calc factor selected hypo and samples
@@ -403,7 +406,8 @@ function _buildHypoCalcFactor(ccwl::CommonConvWrapper, smpid::Integer)
403406 ccwl, #
404407 smpid, # ends in _sampleIdx
405408 varValsHypo, # ends in _legacyParams
406- ccwl. hyporecipe. activehypo # ends in solvefor::Int
409+ ccwl. hyporecipe. activehypo, # ends in solvefor::Int
410+ _slack,
407411 )
408412 return cf
409413end
@@ -427,7 +431,7 @@ function _solveCCWNumeric!(
427431 # target = view(ccwl.varValsAll[][ccwl.varidx[]], smpid)
428432
429433 # SUPER IMPORTANT ON PARTIALS, RESIDUAL FUNCTION MUST DEAL WITH PARTIAL AND WILL GET FULL VARIABLE POINTS REGARDLESS
430- _hypoCalcFactor = _buildHypoCalcFactor (ccwl, smpid)
434+ _hypoCalcFactor = _buildHypoCalcFactor (ccwl, smpid, _slack )
431435
432436 # do the parameter search over defined decision variables using Minimization
433437 sfidx = ccwl. varidx[]
0 commit comments