A method for controlling power production in a distribution grid including a plurality of power producers and a plurality of power consumers, the method comprising the steps of: determining, by a control unit operatively connected to the distribution grid and on the basis of a set of grid parameters, an incoming grid state, the incoming grid state being a future state in which the distribution grid will have a certain set of parameters; the control unit comprising a memory which stores a database, the database being composed of pairs of "state-solution", each of the pairs "state-solution" characterizing a previous grid state and a respective solution for the previous grid state, each solution representing an indication of an amount of power to be produced by the power producers to provide a desired power level for the power consumers in the distribution grid; checking, by the control unit, whether the incoming grid state is similar to at least one of the previous grid states in the database, wherein each pair "state-solution" in the memory is provided with a certain identifier, and wherein said step 2.1 of checking comprises the step of searching for a similar solution for the incoming grid state by using identifiers for the pairs "state-solution" in the database; and wherein the identifier is presented as "xxVyyCPzzPP" where the first characters "xxV" indicate the root-mean-square voltage, "V" equal to "xx", the next characters "yyCP" indicate the amount of consumed power "CP" equal to "yy", and the last characters indicate the amount of produced power "PP" equal to "zz"; if the check result is "yes", selecting, by the control unit, the solution for said at least one previous grid state as a solution for the incoming grid state; and sending, by the control unit, the indication which is represented by the selected solution for the incoming grid state to the power producers. determining, by a control unit operatively connected to the distribution grid and on the basis of a set of grid parameters, an incoming grid state, the incoming grid state being a future state in which the distribution grid will have a certain set of parameters; the control unit comprising a memory which stores a database, the database being composed of pairs of "state-solution", each of the pairs "state-solution" characterizing a previous grid state and a respective solution for the previous grid state, each solution representing an indication of an amount of power to be produced by the power producers to provide a desired power level for the power consumers in the distribution grid; checking, by the control unit, whether the incoming grid state is similar to at least one of the previous grid states in the database, wherein each pair "state-solution" in the memory is provided with a certain identifier, and wherein said step 2.1 of checking comprises the step of searching for a similar solution for the incoming grid state by using identifiers for the pairs "state-solution" in the database; and wherein the identifier is presented as "xxVyyCPzzPP" where the first characters "xxV" indicate the root-mean-square voltage, "V" equal to "xx", the next characters "yyCP" indicate the amount of consumed power "CP" equal to "yy", and the last characters indicate the amount of produced power "PP" equal to "zz"; if the check result is "yes", selecting, by the control unit, the solution for said at least one previous grid state as a solution for the incoming grid state; and sending, by the control unit, the indication which is represented by the selected solution for the incoming grid state to the power producers.