'Non-unique breaks using the cut function in a constrained optimisation problem in R

I'm having trouble using the function cut in an optimisation problem. I'll explain.

What I'm trying to do is separate a column from a dataframe in 10 intervals while respecting many constraints. The goal of the optimisation is to find the 11 numbers giving me the 10 intervals which will allow me to be the closest possible to a reference point. Hence why I'm using the cut function in an optimisation problem.

The problem is that when I try and start the algorithm I always get the same error : Error in cut.default(pd, breaks = int_vf) : 'breaks' are not unique. However, I set up the code so that each break point is stricly higher than the previous one (by the way i'm using the ompr library).

result <- MIPModel() %>%
  add_variable(x1, type = "continuous", lb = 0.0001) %>%
  add_variable(x2, type = "continuous", lb = x1 + 0.01) %>%
  add_variable(x3, type = "continuous", lb = x2 + 0.01) %>%
  add_variable(x4, type = "continuous", lb = x3 + 0.01) %>%
  add_variable(x5, type = "continuous", lb = x4 + 0.01) %>%
  add_variable(x6, type = "continuous", lb = x5 + 0.01) %>%
  add_variable(x7, type = "continuous", lb = x6 + 0.01) %>%
  add_variable(x8, type = "continuous", lb = x7 + 0.01) %>%
  add_variable(x9, type = "continuous", lb = x8 + 0.01) %>%
  add_variable(x10, type = "continuous", lb = x9 + 0.01) %>%
  add_variable(x11, type = "continuous", lb = x10 + 0.01) %>%
  set_objective(obj(c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11)), "min")

The obj is my objective fucntion which calls the cut function.

I don't get how I could have non-unique breakpoints with these parameters but there certainly is something that I am missing. If someone could enligthen me on how the cut function works exctacly in those circumpstances and how to get read of the error that would be of great help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source