This git is a result of an interesting task I recently saw. The task description is the following:
You are given a set of variable tuples
Further you have given a "requirement" for every variable
The objective is to select an optimal combination
This problem can be solved as follows:
We have a two level optimization problem. The first level is the individual level, where each value should be minimized/maximized by itself. The individual level alone would be easy, as just the min/max value could be selected. The problem is, the values are not comparable between each other and do not give a general objective function. They are not comparable as nothing about the domain or distribution of the values is known, just the value itself. In an unweighted setting, comparing the plain values will inevitably lead to putting more weight onto some variables.
To overcome this issue, we create a ranking of the values of each variable. For minimizing a value, the smallest value will get the rank
Now, a general objective function which compares values of each tuple independently is missing. We define this objective function as minimizing the sum of each transformed tuple.
For an unweighted optimization, this solution is optimal:
Take the problem of optimizing
Take the solution we obtained by applying the procedure formulated above and denote this solution with
Consider the case where the solution we obtained is not optimal, which means there is an
This contradicts our initial definition, that
I tested it up to 20 000 000 different tuples and it ran in 30 seconds on my laptop (Intel I5 1035G4)
Generally, we sort n+1 times. Each variable once and then the sum of the variables. Pandas uses numpys quicksort algorithm, which runs in