Hi, I am currently attempting to minimize the energy cost of a water network by determining the most efficient pump schedule. I am using simulator called epanet. My objective function returns the energy cost and my constraint function calculates the non linear constraints from epanet. The input is a pump schedule, a vector of 24 values (0-4) based on the amount of pumps that are active each time period. I will be using a MINLP method (branch and bound) but for that I need to calculate the gradient of my objective function but am having some difficulties. What is the best way to achieve this efficiently?