Skip to content

cardinality matching with exact match #123

@ilovemane

Description

@ilovemane

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)
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions