code: def format_lp(nodes, constraints_x, qa, constraints_y, qb):
      
      lp_handle = cStringIO.StringIO()
  
      lp_handle.write("Maximize\n ")
      records = 0
      for i, score in nodes:
          lp_handle.write("+ %d x%d " % (score, i))
          # SCIP does not like really long string per row
          records += 1
          if records % 10 == 0:
              lp_handle.write("\n")
      lp_handle.write("\n")
  
      num_of_constraints = 0
      lp_handle.write("Subject To\n")
      for c in constraints_x:
          additions = " + ".join("x%d" % (x+1) for x in c)
          lp_handle.write(" %s <= %d\n" % (additions, qa))
      num_of_constraints += len(constraints_x)
  
      # non-self
      if not (constraints_x is constraints_y):
          for c in constraints_y:
              additions = " + ".join("x%d" % (x+1) for x in c)
              lp_handle.write(" %s <= %d\n" % (additions, qb))
          num_of_constraints += len(constraints_y)
  
      print("number of variables (%d), number of constraints (%d)" %
            (len(nodes), num_of_constraints), file=sys.stderr)
  
      lp_handle.write("Binary\n")
      for i, score in nodes:
          lp_handle.write(" x%d\n" % i)
  
      lp_handle.write("End\n")
  
      lp_data = lp_handle.getvalue()
      lp_handle.close()
  
      return lp_data
docs: Maximize
       4 x1 + 2 x2 + 3 x3 + x4
      Subject To
       x1 + x2 <= 1
      End