From 3b7eea7155dcf00913138fbc8a025cd9fd0f9a7e Mon Sep 17 00:00:00 2001 From: kilian Date: Fri, 22 May 2026 11:38:54 +0200 Subject: [PATCH] Dateien nach "ILP" hochladen --- ILP/caffeinesynthesis.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ILP/caffeinesynthesis.py b/ILP/caffeinesynthesis.py index d6ba07a..047ebe8 100644 --- a/ILP/caffeinesynthesis.py +++ b/ILP/caffeinesynthesis.py @@ -46,7 +46,7 @@ VERTICES2 = { VERTICES = ['Xanthine', 'p_{0,0}', 'p_{0,1}', 'p_{0,2}', 'p_{0,3}', 'p_{0,4}', 'p_{0,5}', 'Caffeine'] -NMRLIKELYHOODS = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0] +NMRLIKELYHOODS = [0.0, 0.2, 0.7, 0.1, 0.1, 0.2, 0.7, 0.0] FIXED_FLOWS = { 1: 1, @@ -85,8 +85,25 @@ def build_model(name, hyperedges, vertices, nmrlikelihoods, excluded_support=No if excluded_support: model.addConstr(quicksum(b[e_id] for e_id in excluded_support) <= len(excluded_support) - 1, name="different_hyperedges",) + + #Multiplizier den node Wert mit infow + outflow + + #model.setObjective(quicksum(n[v_id] for v_id in vertices), GRB.MINIMIZE) #Maximize Similarity of Nodes + model.ModelSense = GRB.MAXIMIZE + model.setObjectiveN( + quicksum(n[t_id[0]] * x[e_id] for e_id, (_, t_id) in hyperedges.items() if t_id != []), + index=0, + priority=2, + name="maximize_nmr_similarity", + ) + + model.setObjectiveN( + quicksum(-1 *b[e_id] for e_id in hyperedges), + index=1, + priority=1, + name="minimize_used_hyperedges", + ) - model.setObjective(quicksum(n[v_id] for v_id in vertices), GRB.MINIMIZE) #Maximize Similarity of Nodes return model, x, b def positive_entries(variable_dict, threshold=0.5):