dirkschumacher / rcbc

COIN-OR branch and cut (CBC) bindings for R
https://dirkschumacher.github.io/rcbc/
Other
19 stars 5 forks source link

solver returns not integer decision variables #52

Open giadasp opened 3 years ago

giadasp commented 3 years ago

Dear developers, I tried to use your package for a personal project I'm working on. I specified the model as follows:

       result <- rcbc::cbc_solve(
            is_integer = c(FALSE, rep.int(TRUE, n_total - 1)),
            col_lb = rep.int(0, n_total),
            col_ub = c(Inf, rep.int(1, n_total - 1)),
            max = FALSE,
            cbc_args = list("SEC" = "10"),
            obj = c(1, rep.int(0, n_total-1),
            mat = <large matrix with n_total columns and n_row rows>,
            row_lb = <vector with n_rows elements>
       )

The solver says that it found an optimal solution, but when I try to retrieve the solution I get non-integer values for all the variables. For example, I have negative values and values bigger than one with some decimals. I tried to use rep.int() instead of rep() because in the default values for the arguments you used it. Can you explain why this happens? Should I take only the absolute values of the results and round them to 0 or 1? I used cbc with other interfaces before and I didn't have this problem.

giadasp commented 3 years ago

I saw that (sometimes) the solver printed its log in the R console and it said that the model was infeasible. That's why the solution was not an integer. Thus, it seems that the status that rcbc gives is not equal to the status of the cbc model: infeasible!=model has solution. So I close the issue but I think that you should make the package print the right status of the model.

dirkschumacher commented 3 years ago

Thanks a lot for the issue. Can you provide a reproducible example that highlights your problem?

giadasp commented 1 year ago

Sorry but I cannot reproduce it since I'm not working on that project anymore :(