Skip to content

Commit

Permalink
Merge pull request #27 from LouisLeNezet/solve_qp
Browse files Browse the repository at this point in the history
SolveQP Align bug
  • Loading branch information
sinnweja authored Jun 8, 2023
2 parents 3f71b6c + df4dc23 commit 4fd94a1
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions R/alignped4.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,33 @@ alignped4 <- function(rval, spouse, level, width, align) {

if (exists("solve.QP")) {
pp <- t(pmat) %*% pmat + 1e-8 * diag(ncol(pmat))
fit <- solve.QP(pp, rep(0., n), t(cmat), dvec)
fit <- tryCatch(
{
solve.QP(pp, rep(0., n), t(cmat), dvec)
},
warning = function(w) {
message(Solve QP ended with a warning)
message()(w)
return(NA)
},
error = function(e) {
message(Solve QP ended with an error)
message(w)
return(NA)
}
)

} else {
stop("Need the quadprog package")
}

newpos <- rval$pos
# fit <- lsei(pmat, rep(0, nrow(pmat)), G=cmat, H=dvec)
# newpos[myid>0] <- fit$X[myid]
newpos[myid > 0] <- fit$solution[myid]

if (length(fit) > 1) {
newpos[myid > 0] <- fit$solution[myid]
}

newpos
}

0 comments on commit 4fd94a1

Please sign in to comment.