The application of gradient-only optimization methods for problems discretized using non-constant methods