Demand response provides more flexibility in the operation of a power grid with high renewable energy penetration. In this paper, a mathematical model of storage devices and loads with thermal inertia, such as batteries, water heaters, and air conditioners, is presented. Dynamic and linear programming methods are used to solve the optimization problem subject to comfort constraints. The price signal for these devices can incorporate financial criteria as well as reliability criteria. Optimal operation of the storage devices and loads with thermal inertia are obtained considering the given price signal. Individual device performance optimization is compared with all of the devices as a single solution and optimal operation plots and results are presented and discussed. The presented optimization problem for house devices is solved using dynamic programming and mathematical programming and the results are compared.