Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

can't use gekko equation

$
0
0

i want to define an equation in gekko, but than comes the error:

Traceback (most recent call last):  File "/Users/stefantomaschko/Desktop/Bundeswettbewerb Informatik/2.Runde/Päckchen/paeckchen_gurobi.py", line 131, in <module>    m.solve()  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gekko/gekko.py", line 2166, in solve    raise Exception(apm_error)Exception: @error: Equation Definition Equation without an equality (=) or inequality (>,<) true STOPPING...

my Code (not all functions, but the most important):

def fitness(var):    anzahl_sorte_stil = {}    boxes = convert(var)    print(boxes)    stile = set()    for var_box in var:        #anzahl_box = []        for v in var_box:            try:                value = int(str(v.value))            except:                value = int(float(str(v.value[0])))# if v.value != None else 0            info = info_name(v)            stile.add(info[1])            if info not in anzahl_sorte_stil:                anzahl_sorte_stil[info] = value            else:                anzahl_sorte_stil[info] += value            #anzahl_box.append(value)    #   if min(anzahl_box) == 0:    gruppen = finde_gruppen(stile)    for g in gruppen:        if g not in kombinierbar:            return unmoeglich    #print(anzahl_sorte_stil)    uebrig = 0    for kleid in kleider:        dif = kleid[2] - anzahl_sorte_stil[(kleid[0],kleid[1])]        if dif<0:            print("ZU OFT VERWENDET!")            return unmoeglich        else:            uebrig += dif    return uebrigsorten,stile,kombinierbar,kleider,gesamt = read_data("paeckchen0.txt")unmoeglich = gesamt+1min_boxen,max_boxen = get_min_max_boxen(sorten,kleider)print("Min. Anzahl Boxen: ", min_boxen)print("Max. Anzahl Boxen: ", max_boxen)m = GEKKO(remote=False)m.options.max_time = 1000m.options.max_iter = 1000m.options.max_memory = 1000var = [[] for _ in range(max_boxen)]for i,var_box in enumerate(var):    for kleid in kleider:        #print(kleid[:2])        var_box.append(m.Var(0,lb=1,ub=min((kleid[2],3)),integer=True,name=f"{kleid[0]}_{kleid[1]}_{i}"))#wie oft ist Kleid {kleid[:2]} in Box {i}#m.Equation(fitness(var) < gesamt)m.Minimize(fitness(var))m.Equation(fitness(var) <= unmoeglich)m.options.SOLVER=1m.solve()

in the docmentation i didnt found anything related to that. can anybody help me to change it. I would also be happy about some looks at my code and why it did not find the right solution. now i want to implement the equation to not even allow incorrect solutions.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>