This thesis deals with the subject of economic optimization of energy production. An initial theoretical part present the various input data required for an optimization. The most basic inputs are the forecasts of district heating load, forecast of electricity price and cost functions. Some different optimization methods used for economic optimization of energy is described. An example of how to solve an optimization problem of type "Mixed integer programming" by the “Branch-and-bound” method is found in Appendix 2. A description of an existing energy system, which is a part of a later analysis, has been made. This energy system consists of a power plant, waste boilers, oil fired hot water boilers and a heat pump system. A summary of a soft...