code: def numpart_qaoa(asset_list, A=1.0, minimizer_kwargs=None, steps=1):
      
      cost_operators = []
      ref_operators = []
      for ii in range(len(asset_list)):
          for jj in range(ii + 1, len(asset_list)):
              cost_operators.append(PauliSum([PauliTerm("Z", ii, 2*asset_list[ii]) *
                                              PauliTerm("Z", jj, A*asset_list[jj])]))
          ref_operators.append(PauliSum([PauliTerm("X", ii, -1.0)]))
  
      cost_operators.append(PauliSum([PauliTerm("I", 0, len(asset_list))]))
  
      if minimizer_kwargs is None:
          minimizer_kwargs = {'method': 'Nelder-Mead',
                              'options': {'ftol': 1.0e-2,
                                          'xtol': 1.0e-2,
                                          'disp': True}}
  
      qc = get_qc(f"{len(asset_list)}q-qvm")
  
      qaoa_inst = QAOA(qc, list(range(len(asset_list))), steps=steps, cost_ham=cost_operators,
                       ref_ham=ref_operators, store_basis=True,
                       minimizer=minimize, minimizer_kwargs=minimizer_kwargs,
                       vqe_options={'disp': print})
  
      return qaoa_inst
docs: generate number partition driver and cost functions
  
      :param asset_list: list to binary partition
      :param A: (float) optional constant for level separation. Default=1.
      :param minimizer_kwargs: Arguments for the QAOA minimizer
      :param steps: (int) number of steps approximating the solution.