コード例 #1
0
def encode_equiv_radius(path1, path2, input_los, input_his, equiv_mode, center, radius, metric, name):
    # accepts one_hot_partial_top_k as mode

    fc.use_asymmetric_bounds = True
    fc.use_context_groups = True
    fc.use_grb_native = False
    fc.use_eps_maximum = True
    fc.manhattan_use_absolute_value = True
    fc.epsilon = 1e-4

    enc = Encoder()
    enc.encode_equivalence_from_file(path1, path2, input_los, input_his, equiv_mode, equiv_mode)
    enc.add_input_radius(center, radius, metric)

    enc.optimize_constraints()

    k = int(equiv_mode.split('_')[-1])

    model = create_gurobi_model(enc.get_vars(), enc.get_constraints(), name)
    diff = model.getVarByName('E_diff_0_{num}'.format(num=k))
    model.setObjective(diff, grb.GRB.MAXIMIZE)
    model.setParam('TimeLimit', 30 * 60)

    # maximum for diff should be greater 0
    return model
コード例 #2
0
def encode_r_opt(path1, path2, inl, inh, center, radius_lo, radius_hi, mode, time_limit=30*60):
    fc.use_asymmetric_bounds = True
    fc.use_context_groups = True
    fc.use_grb_native = False
    fc.use_eps_maximum = True
    fc.manhattan_use_absolute_value = True
    fc.epsilon = 1e-4
    fc.not_equiv_tolerance = 1e-2

    enc = Encoder()
    enc.encode_equivalence_from_file(path1, path2, inl, inh, mode, mode)
    enc.add_input_radius(center, radius_hi, radius_mode='variable', radius_lo=radius_lo)

    enc.optimize_constraints()

    model = create_gurobi_model(enc.get_vars(), enc.get_constraints())
    r = model.getVarByName('r_0_0')
    model.setObjective(r, grb.GRB.MINIMIZE)
    model.setParam('TimeLimit', time_limit)

    return enc, model