code: def network_lopf_prepare_solver(network, solver_name="glpk", solver_io=None):
      
  
      network.opt = SolverFactory(solver_name, solver_io=solver_io)
  
      patch_optsolver_record_memusage_before_solving(network.opt, network)
  
      if isinstance(network.opt, PersistentSolver):
          network.opt.set_instance(network.model)
  
      return network.opt
docs: Prepare solver for linear optimal power flow.
  
      Parameters
      ----------
      solver_name : string
          Must be a solver name that pyomo recognises and that is
          installed, e.g. "glpk", "gurobi"
      solver_io : string, default None
          Solver Input-Output option, e.g. "python" to use "gurobipy" for
          solver_name="gurobi"
  
      Returns
      -------
      None