Refactoring graphical optimization to receive a generic f(x[]), so I can use it as visualization output for the next optimization algorithms