The demand response and accommodation of different renewable energy resources are essential factors in a modern smart microgrid. This paper investigates the energy management related to the short-term (24 h) unit commitment and demand response in a factory power system with uncertain photovoltaic power generation. Elastic loads may be activated subject to their operation constraints in a manner determined by the electricity prices while inelastic loads are inflexibly fixed in each hour. The generation of power from photovoltaic arrays is modeled as a Gaussian distribution owing to its uncertainty. This problem is formulated as a stochastic mixed-integer optimization problem and solved using two levels of algorithms: the master level determines the optimal states of the units (e.g., micro-turbine generators) and elastic loads; and the slave level concerns optimal real power scheduling and power purchase/sale from/to the utility, subject to system operating constraints. This paper proposes two novel encoding schemes used in genetic algorithms on the master level; the point estimate method, incorporating the interior point algorithm, is used on the slave level. Various scenarios in a 30-bus factory power system are studied to reveal the applicability of the proposed method.