I'm using GEKKO for solving a nonlinear programming problem. My goal is to compare the GEKKO performance with an alternative, and so I want to make sure that I'm getting from GEKKO the best it can offer.
There are n binary variables, each of them is assigned a weight, each of the weights is a number from the interval [0, 1] (i.e., a rational number w satisfying 0<= w <= 1). Each of the constraints is linear. The objective function is non-linear: it is the product of weights of the non-zero variables, and the goal is to maximize the product.
I started with specifying the objective function as
m.Obj(-np.prod([1 - variables[i] + weights[i] * variables[i] for i in range(len(variables))]))
but then I would bump into APM model error: string > 15000 characters. So I switched to auxiliary variables using the if3 function as
aux_variables = [m.if3(variables[i], weights[i], 1) for i in range(len(variables))]
m.Obj(-np.prod(aux_variables))
The only global parameters that I'm setting manually are in the following code.
# initialize model
m = GEKKO(remote=False)
# set global variables
m.options.SOLVER = 1 # APOPT solver
# "APOPT is an MINLP solver"
# "APOPT is also the only solver that handles Mixed Integer problems."
m.options.IMODE = 3 # steady state optimization
m.solver_options = ['minlp_maximum_iterations 500', \
# minlp iterations with integer solution
'minlp_max_iter_with_int_sol 10', \
# treat minlp as nlp
'minlp_as_nlp 0', \
# nlp sub-problem max iterations
'nlp_maximum_iterations 50', \
# 1 = depth first, 2 = breadth first
'minlp_branch_method 1', \
# maximum deviation from whole number
'minlp_integer_tol 0.05', \
# covergence tolerance
'minlp_gap_tol 0.01']
# initialize variables
variables = m.Array(m.Var, (number_of_vars), lb=0, ub=1, integer=True)
# set initial values
for var in variables:
var.value = 1
Question:
what more, if anything, can I do, in terms of global parameters and formulation of the objective function, to optimize the GEKKO's performance for this particular problem?
At the same time, I would love GEKKO to produce decent results.