A General Approach of Automated Environment Design for Learning the Optimal Power Flow