<jupyter_start><jupyter_text>The skeleton for the cut callback functions<jupyter_code>from gurobipy import GRB, quicksum
def mincut_callback(model, where):

    if model._impcounter < 10 and where == GRB.Callback.MIPNODE:
        if model.cbGet(GRB.Callback.MIPNODE_NODCNT) != 0: return
        
        relaxation_objval = model.cbGet(GRB.Callback.MIPNODE_OBJBND)
        if model._relobj is not None:
            imp = (model._relobj - relaxation_objval) / model._relobj
            if imp < 0.005: 
                model._impcounter += 1
            else:
                model._impcounter = 0
        model._relobj = relaxation_objval

        for i in range(model._k):
            capacities = model.cbGetNodeRel(model._vars[i])
            cutsets = model._cutfinder.get_cutsets(capacities)
            for (u, v, cutset) in cutsets:
                cutset_expr = quicksum(model._vars[i][j] for j in cutset)
                model.cbCut(cutset_expr >= model._vars[i][u] + model._vars[i][v] - 1)
        
    elif where == GRB.Callback.MIPSOL:
        for i in range(model._k):
            capacities = model.cbGetSolution(model._vars[i])
            cutsets = model._cutfinder.get_cutsets(capacities)
            for (u, v, cutset) in cutsets:
                cutset_expr = quicksum(model._vars[i][j] for j in cutset)
                model.cbLazy(cutset_expr >= model._vars[i][u] + model._vars[i][v] - 1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1063238359972203, 'fraction_numerical': 0.007644197359277276, 'mean_word_length': 2.2653061224489797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '437654', 'license': 'MIT', 'n_tokens_mistral': 489, 'n_tokens_neox': 470, 'n_words': 96, 'path': 'notebooks/cut_callback.ipynb', 'repo_name': 'Behrouz-Babaki/graph_clustering', 'size': '1439'}