Skip to content

Commit

Permalink
DS-3465: Add check that CVXR found feasible solution
Browse files Browse the repository at this point in the history
* Bad input data can lead to infeasible optimization problems, add code to
check status from CVXR::solve and error if necessary
* DS-3465, DS-3458 [revdep skip]
  • Loading branch information
mwmclean committed Aug 13, 2021
1 parent 4562d62 commit 909f582
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions R/weightingdialog.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ computeWeightsDialog <- function(adjustment.variables, has.numerics, margins, in
Phi_R = Minimize(sum(input.weight * (-entr((g - lower) / (upper - lower)) - (entr((upper - g) / (upper - lower))))))
p = Problem(Phi_R, constraints)
res = solve(p)
checkSolverStatus(res)
as.numeric(input.weight * res$getValue(g))
} else {
weights(calibrate(svydesign(ids = ~1, weights = ~input.weight, data = adjustment.variables),
Expand Down

0 comments on commit 909f582

Please sign in to comment.