A Knowledge-Based Framework for Power Flow and Optimal Power Flow Analyses