A two-level approach to large mixed-integer programs with application to cogeneration in energy-efficient buildings