docs: def get_opt_add_remove_edges_greedy(instance):
    '''
     only apply with elementary path consistency notion
    '''
    sem        = [sign_cons_prg, elem_path_prg, fwd_prop_prg, bwd_prop_prg]
    inst       = instance.to_file()
    prg        = [ inst, remove_edges_prg,
                   min_repairs_prg, show_rep_prg
                 ] + sem + scenfit
    coptions   = '1 --project --opt-strategy=5 --opt-mode=optN --quiet=1'
    solver     = GringoClasp(clasp_options=coptions)
    models     = solver.run(prg, collapseTerms=True, collapseAtoms=False)
  
    bscenfit   = models[0].score[0]
    brepscore  = models[0].score[1]
  
    #print('model:   ',models[0])
    #print('bscenfit:   ',bscenfit)
    #print('brepscore:  ',brepscore)
  
  
    strt_edges = TermSet()
    fedges     = [(strt_edges, bscenfit, brepscore)]
    tedges     = []
    dedges     = []
    coptions   = '0 --project --opt-strategy=5 --opt-mode=optN --quiet=1'
    solver     = GringoClasp(clasp_options=coptions)
  
    while fedges:
  #    sys.stdout.flush()
  #    print ("TODO: ",len(fedges))
      (oedges, oscenfit, orepscore) = fedges.pop()
  
  #    print('(oedges,oscenfit, orepscore):',(oedges,oscenfit, orepscore))
  #    print('len(oedges):',len(oedges))
  
      # extend till no better solution can be found
      end       = True # assume this time its the end
      f_oedges  = TermSet(oedges).to_file()
      prg       = [ inst, f_oedges, remove_edges_prg, best_one_edge_prg,
                    min_repairs_prg, show_rep_prg
                  ] + sem + scenfit
      models    = solver.run(prg, collapseTerms=True, collapseAtoms=False)
      nscenfit  = models[0].score[0]
      nrepscore = models[0].score[1]+2*(len(oedges))
  
  #    print('nscenfit:   ',nscenfit)
  #    print('nrepscore:  ',nrepscore)
  
      if (nscenfit < oscenfit) or nrepscore < orepscore: # better score or more that 1 scenfit
  #      print('maybe better solution:')
  #      print('#models: ',len(models))
  
        for m in models:
          #print('MMM   ',models)
          nend = TermSet()
          for a in m :
            if a.pred() == 'rep' :
              if a.arg(0)[0:7]=='addeddy' :
  #              print('new addeddy to',a.arg(0)[8:-1])
                nend  = String2TermSet('edge_end('+(a.arg(0)[8:-1])+')')
  
                # search starts of the addeddy
  #              print('search best edge starts')
                f_end  = TermSet(nend).to_file()
  
                prg    = [ inst, f_oedges, remove_edges_prg, f_end, best_edge_start_prg,
                           min_repairs_prg, show_rep_prg
                         ] + sem + scenfit
                starts = solver.run(prg, collapseTerms=True, collapseAtoms=False)
                os.unlink(f_end)
  #              print(starts)
                for s in starts:
                  n2scenfit  = s.score[0]
                  n2repscore = s.score[1]+2*(len(oedges))
  #                print('n2scenfit:   ', n2scenfit)
  #                print('n2repscore:  ', n2repscore)
  
                  if (n2scenfit < oscenfit) or n2repscore < orepscore: # better score or more that 1 scenfit
  #                  print('better solution:')
                    if (n2scenfit<bscenfit):
                      bscenfit  = n2scenfit # update bscenfit
                      brepscore = n2repscore
                    if (n2scenfit == bscenfit) :
                      if (n2repscore<brepscore) : brepscore = n2repscore
  
                    nedge = TermSet()
                    for a in s :
                      if a.pred() == 'rep' :
                        if a.arg(0)[0:7]=='addedge' :
  #                        print('new edge ',a.arg(0)[8:-1])
                          nedge = String2TermSet('obs_elabel('+(a.arg(0)[8:-1])+')')
                          end   = False
  
                    nedges = oedges.union(nedge)
                    if (nedges,n2scenfit,n2repscore) not in fedges and nedges not in dedges:
                      fedges.append((nedges,n2scenfit,n2repscore))
                      dedges.append(nedges)
  
      if end :
        if (oedges,oscenfit,orepscore) not in tedges and oscenfit == bscenfit and orepscore == brepscore:
  #        print('LAST tedges append',oedges)
          tedges.append((oedges,oscenfit,orepscore))
  
      # end while
      os.unlink(f_oedges)
  
    # take only the results with the best scenfit
    redges=[]
    for (tedges,tscenfit,trepairs) in tedges:
      if tscenfit == bscenfit: redges.append((tedges,trepairs))
  
    os.unlink(inst)
    return (bscenfit,redges)