Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cardinality matching with exact match #123

Open
ilovemane opened this issue Aug 8, 2022 · 2 comments
Open

cardinality matching with exact match #123

ilovemane opened this issue Aug 8, 2022 · 2 comments

Comments

@ilovemane
Copy link

Hi, I found that if I use cardinality matching with exact matching, it often comes back without a solution, when an exact match on a variable with loads of categories (e.g. on a dataset with loads of clusters). I guess it due to that, if any of the clusters fail to comes back with a solution then the whole dataset won't return a solution. But in I think what we want is to exclude all the data in that clusters if it won't give a solution with cardinality match instead. I hope this makes sense to you. I think is due to these checks in the function below.

thanks,

Mike

cardinality_error_report <- function(out, solver) {
if (solver == "glpk") {
if (out$status == 1) {
if (all(out$solution == 0)) {
stop("The optimization problem may be infeasible. Try increasing the value of 'tols'.\nSee ?method_cardinality for additional details.", call. = FALSE)
}
else {
warning("The optimizer failed to find an optimal solution in the time alotted. The returned solution may not be optimal.\nSee ?method_cardinality for additional details.", call. = FALSE)
}
}
}
else if (solver == "symphony") {
if (names(out$status) %in% c("TM_TIME_LIMIT_EXCEEDED") && !all(out$solution == 0) && all(out$solution <= 1)) {
warning("The optimizer failed to find an optimal solution in the time alotted. The returned solution may not be optimal.", call. = FALSE)
}
else if (names(out$status) != "TM_OPTIMAL_SOLUTION_FOUND") {
stop("The optimizer failed to find an optimal solution in the time alotted. The optimization problem may be infeasible. Try increasing the value of 'tols'.\nSee ?method_cardinality for additional details.", call. = FALSE)
}
}
else if (solver == "gurobi") {
if (out$status %in% c("TIME_LIMIT", "SUBOPTIMAL") && !all(out$x == 0)) {
warning("The optimizer failed to find an optimal solution in the time alotted. The returned solution may not be optimal.\nSee ?method_cardinality for additional details.", call. = FALSE)
}
else if (out$status %in% c("INFEASIBLE", "INF_OR_UNBD", "NUMERIC") || all(out$x == 0)) {
stop("The optimization problem may be infeasible. Try increasing the value of 'tols'.\nSee ?method_cardinality for additional details.", call. = FALSE)
}
}
}

@ngreifer
Copy link
Collaborator

ngreifer commented Aug 9, 2022

This is a great suggestion; I will look into implementing it.

@ilovemane
Copy link
Author

ilovemane commented Aug 9, 2022

Cool thanks! The cardinality part of this package is fantastic btw, it really helps me with my thesis!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants