# Modeling language for large-scale linear, quadratic, nonlinear, # and mixed-integer programming. # Supported solvers: APOPT, BPOPT, IPOPT, SNOPT, and MINOS #pip install gekko in conda window from gekko import GEKKO # Define environment prob = GEKKO(remote=False) # Design variables x = prob.Var(lb=0,ub=None,integer=True) y = prob.Var(lb=0,ub=None) # Objective function prob.Obj(-(2*x+5*y)) # Add constraints to the environment prob.Equation(5*x+3*y<=10) prob.Equation(2*x+7*y<=9) # Solve the problem (1 = MINLP solver, 2,3: Other Solvers) prob.options.SOLVER=1 prob.solve(disp=False) print('Results:') print('x = ' + str(x.value)) print('y = ' + str(y.value)) print('Optimal value of obj = ' + str(-prob.options.objfcnval)) #Results: #x = [1.0] #y = [1.0] #Optimal value of obj = 7.0
Recent Comments