text_plain_output_1.png
from gekko import GEKKO

from gekko import GEKKO

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import time

import time

import numpy as np
import pandas as pd
from gekko import GEKKO
import time
m = GEKKO()
m.options.SOLVER = 1
m.solver_options = ['minlp_maximum_iterations 500', 'minlp_max_iter_with_int_sol 10', 'minlp_as_nlp 0', 'nlp_maximum_iterations 50', 'minlp_branch_method 1', 'minlp_integer_tol 0.05', 'minlp_gap_tol 0.01']
df = pd.read_csv('../input/junkchanged/cloulet_dataset.csv')
max_elementb = df['Bandwidth'].max()
max_elementc = df['Capacity'].max()
start_time = time.time()
main_allocation = m.Var(value=max_elementc, lb=max_elementc, ub=max_elementc)
others_allocation = m.Var(value=max_elementc, lb=0, ub=max_elementb)
b = m.Var(value=max_elementb, lb=max_elementb, ub=max_elementb)
m.Equation(main_allocation * others_allocation <= b)
m.Maximize(main_allocation + others_allocation)
m.solve(disp=False)

import numpy as np
import pandas as pd
from gekko import GEKKO
import time
m = GEKKO()
m.options.SOLVER = 1
m.solver_options = ['minlp_maximum_iterations 50000']
df = pd.read_csv('../input/junkchanged/cloulet_dataset.csv')
bw = df['Bandwidth']
cp = df['Capacity']
print(bw)
print(cp)
n = len(bw)
start_time = time.time()
x = m.Array(m.Var, n)
for i in range(n):
    x[i] = m.Var(lb=0, ub=cp[i], integer=True)
s = m.sum([x[i] for i in range(n)])
for i in range(n):
    m.Equation(x[i] * s - x[i] * x[i] <= bw[i])
m.Maximize(s)
m.solve(disp=False)
print('total allocation', s.value)
for i in range(n):
    print(x[i].value, ' capacity ', cp[i], '  bandwidth ', bw[i])
print('execution time', time.time() - start_time)