<commit_before>from nifty import *





def greedyAdditiveProposals(sigma=1.0, weightStopCond=0.0, nodeNumStopCond=-1.0):
    s = graph.multicut.FusionMoveBasedGreedyAdditiveProposalGenSettingsUndirectedGraph()
    s.sigma = float(sigma)
    s.weightStopCond = float(weightStopCond)
    s.nodeNumStopCond = float(nodeNumStopCond)
    return s

def watershedProposals(sigma=1.0, seedFraction=0.0):
    s = graph.multicut.FusionMoveBasedWatershedProposalGenSettingsUndirectedGraph()
    s.sigma = float(sigma)
    s.seedFraction = float(seedFraction)
    return s

def greedyAdditiveFactory(verbose=0):
    s = graph.multicut.MulticutGreedyAdditiveSettingsUndirectedGraph()
    s.verbose = int(verbose)
    factory = graph.multicut.MulticutGreedyAdditiveFactoryUndirectedGraph(s)
    return factory




def ilpSettings(relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    s = graph.multicut.IlpBackendSettings()
    s.relativeGap = float(relativeGap)
    s.absoluteGap = float(absoluteGap)
    s.memLimit = float(memLimit)

    return s

def multicutIlpCplexFactory(verbose=0, addThreeCyclesConstraints=True,
                            addOnlyViolatedThreeCyclesConstraints=True,
                            relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0
                            ):
    s = graph.multicut.MulticutIlpCplexSettingsUndirectedGraph()
    s.verbose = int(verbose)
    s.addThreeCyclesConstraints = bool(addThreeCyclesConstraints)
    s.addOnlyViolatedThreeCyclesConstraints = bool(addOnlyViolatedThreeCyclesConstraints)
    s.ilpSettings = ilpSettings(relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)
    factory = graph.multicut.MulticutIlpCplexFactoryUndirectedGraph(s)
    return factory

def multicutIlpGurobiFactory(verbose=0, addThreeCyclesConstraints=True,
                            addOnlyViolatedThreeCyclesConstraints=True,
                            relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    s = graph.multicut.MulticutIlpGurobiSettingsUndirectedGraph()
    s.verbose = int(verbose)
    s.addThreeCyclesConstraints = bool(addThreeCyclesConstraints)
    s.addOnlyViolatedThreeCyclesConstraints = bool(addOnlyViolatedThreeCyclesConstraints)
    s.ilpSettings = ilpSettings(relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)
    factory = graph.multicut.MulticutIlpGurobiFactoryUndirectedGraph(s)
    return factory

def multicutIlpFactory( ilpSolver = 'cplex',
                        verbose=0, addThreeCyclesConstraints=True,
                        addOnlyViolatedThreeCyclesConstraints=True,
                        relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    
    if ilpSolver == 'cplex':
        f = multicutIlpCplexFactory
    else:
        f = multicutIlpGurobiFactory
    return f(verbose=verbose,addThreeCyclesConstraints=addThreeCyclesConstraints,
            addOnlyViolatedThreeCyclesConstraints=addOnlyViolatedThreeCyclesConstraints,
            relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)

def fusionMoveSettings(mcFactory=greedyAdditiveFactory()):
    s = graph.multicut.FusionMoveSettingsUndirectedGraph()
    s.mcFactory = mcFactory<commit_msg>added mem limit parameter and made gaps available<commit_after>from nifty import *





def greedyAdditiveProposals(sigma=1.0, weightStopCond=0.0, nodeNumStopCond=-1.0):
    s = graph.multicut.FusionMoveBasedGreedyAdditiveProposalGenSettingsUndirectedGraph()
    s.sigma = float(sigma)
    s.weightStopCond = float(weightStopCond)
    s.nodeNumStopCond = float(nodeNumStopCond)
    return s

def watershedProposals(sigma=1.0, seedFraction=0.0):
    s = graph.multicut.FusionMoveBasedWatershedProposalGenSettingsUndirectedGraph()
    s.sigma = float(sigma)
    s.seedFraction = float(seedFraction)
    return s

def greedyAdditiveFactory(verbose=0):
    s = graph.multicut.MulticutGreedyAdditiveSettingsUndirectedGraph()
    s.verbose = int(verbose)
    factory = graph.multicut.MulticutGreedyAdditiveFactoryUndirectedGraph(s)
    return factory




def ilpSettings(relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    s = graph.multicut.IlpBackendSettings()
    s.relativeGap = float(relativeGap)
    s.absoluteGap = float(absoluteGap)
    s.memLimit = float(memLimit)

    return s

def multicutIlpCplexFactory(verbose=0, addThreeCyclesConstraints=True,
                            addOnlyViolatedThreeCyclesConstraints=True,
                            relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    s = graph.multicut.MulticutIlpCplexSettingsUndirectedGraph()
    s.verbose = int(verbose)
    s.addThreeCyclesConstraints = bool(addThreeCyclesConstraints)
    s.addOnlyViolatedThreeCyclesConstraints = bool(addOnlyViolatedThreeCyclesConstraints)
    s.ilpSettings = ilpSettings(relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)
    factory = graph.multicut.MulticutIlpCplexFactoryUndirectedGraph(s)
    return factory

def multicutIlpGurobiFactory(verbose=0, addThreeCyclesConstraints=True,
                            addOnlyViolatedThreeCyclesConstraints=True,
                            relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    s = graph.multicut.MulticutIlpGurobiSettingsUndirectedGraph()
    s.verbose = int(verbose)
    s.addThreeCyclesConstraints = bool(addThreeCyclesConstraints)
    s.addOnlyViolatedThreeCyclesConstraints = bool(addOnlyViolatedThreeCyclesConstraints)
    s.ilpSettings = ilpSettings(relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)
    factory = graph.multicut.MulticutIlpGurobiFactoryUndirectedGraph(s)
    return factory

def multicutIlpFactory( ilpSolver = 'cplex',
                        verbose=0, addThreeCyclesConstraints=True,
                        addOnlyViolatedThreeCyclesConstraints=True,
                        relativeGap=0.0, absoluteGap=0.0, memLimit=-1.0):
    
    if ilpSolver == 'cplex':
        f = multicutIlpCplexFactory
    elif ilpSolver == 'gurobi':
        f = multicutIlpGurobiFactory
    else:
        raise RuntimeError("%s is an unknown ilp solver"%str(ilpSolver))
    return f(verbose=verbose,addThreeCyclesConstraints=addThreeCyclesConstraints,
            addOnlyViolatedThreeCyclesConstraints=addOnlyViolatedThreeCyclesConstraints,
            relativeGap=relativeGap, absoluteGap=absoluteGap, memLimit=memLimit)

def fusionMoveSettings(mcFactory=greedyAdditiveFactory()):
    s = graph.multicut.FusionMoveSettingsUndirectedGraph()
    s.mcFactory = mcFactory
{'fraction_non_alphanumeric': 0.08090965346534654, 'fraction_numerical': 0.011757425742574257, 'mean_word_length': 4.027216174183515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6514151', 'n_tokens_mistral': 2068, 'n_tokens_neox': 2015, 'n_words': 272}