Relative Content

Tag Archive for roptimizationmaximize

R – Maximize Column Value across Non Overlapping Intervals

I have a maximization problem where I have two columns the represent an interval (between 0 and 1) and a third column that has value that I need to maximize. The interval columns overlap and in my real life problem, I have thousands of rows. The third column (‘Value _to _Maximize’) where I want to first select the highest value, then search forwards and backwards to find the next highest values that do not have overlapping intervals with previous highs/maximized values. Below is the code that has the three columns mentioned above as well as a 4th column that selects the optimal/expected output called ‘Rows_Choosen’. A “1” indicates it is the row chosen.