In this paper, we consider the application of mathematical optimization models to energy problems. Using the latest information technology, we try to utilize renewable energy whose output is unstable. Such efforts are collectively called smart communities. Stochastic programming deals with optimization under uncertain conditions. Since the output of solar power generation in a smart community is uncertain, application of stochastic programming is required. Considering practical operational constraints, this model becomes a stochastic programming problem involving nonlinear recourse, which cannot be solved with typical solvers directly. The problem can be reformulated as a large-scale mixed integer programming problem by piecewise linear approximation to obtain an optimal solution. In our algorithm, we add points for piecewise linear approximation iteratively and increase accuracy of the approximation. In numerical experiments, the effectiveness of the stochastic programming model is shown by comparing it with the deterministic model. Moreover, we calculate a recovery period of investment cost for photovoltaic generation and a storage battery and show usefulness of our model when evaluating a practical operation.