BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
594 stars 104 forks source link

Gekko - APMonitor Optimization Suite doesn't converge for a MINLP problem with linear-fractional objective function #154

Closed guanghuidatafuelx closed 1 year ago

guanghuidatafuelx commented 1 year ago

Gekko - APMonitor Optimization Suite is unable to solve an optimization problem. I am trying to solve Max a^Tx/b^Tx with the constraint d<=c^Tx <=e, where the decision vector x=[x_1, x_2, ..., x_n] are non-negative integers, and vectors a,b,c are positive real-number vectors, and constants d and e are positive lower and upper bounds. The problem is feasible because I got a feasible solution with the objective being replaced by 0. I was wondering whether APMonitor is capable of solving linear-fractional objective problems or not.

Anyone has experience with how to handle this kind of issues? Is there any options in the solver I could try to turn on to resolve the issue?

I uploaded the files below in txt. The apm file is here

gk_model0.apm.txt

The csv file gk_model0.csv.txt

The model info file gk_model0.info.txt

The infeasibility file

infeasibilities.txt

The output looks like below, where the solver status is inconsistent with APPSTATUS and APPINFO. This may be a APMonitor reporting issue.

apm 67.162.115.84_gk_model0
 ----------------------------------------------------------------
APMonitor, Version 1.0.1
APMonitor Optimization Suite

--------- APM Model Size ------------ Each time step contains Objects : 7 Constants : 0 Variables : 5626 Intermediates: 0 Connections : 4914 Equations : 4913 Residuals : 4913

Number of state variables: 5626 Number of total equations: - 4919 Number of slack variables: - 2

Degrees of freedom : 705


Steady State Optimization with APOPT Solver

Iter: 1 I: -9 Tm: 75.50 NLPi: 251 Dpth: 0 Lvs: 0 Obj: 0.00E+00 Gap: NaN Warning: no more possible trial points and no integer solution Maximum iterations


Solver : APOPT (v1.0) Solution time : 75.5581999999995 sec Objective : NaN Unsuccessful with error code 0

Creating file: infeasibilities.txt Use command apm_get(server,app,'infeasibilities.txt') to retrieve file @error: Solution Not Found Not successful Gekko Solvetime: 1.0 s

#################################################

APPINFO = 0 - a successful solution APPSTATUS =1 - solver converges to a successful solution

Solver status - Not successful, exception thrown

decision variable =[0,0, ...,0].

APMonitor commented 1 year ago

Try using m.options.SOLVER=3 and m.solve() to initialize and then switch back to m.options.SOLVER=1 with m.solve() to get an integer solution. Could you post your original Gekko code and the question on Stack Overflow? Here are related Gekko questions: https://stackoverflow.com/questions/tagged/gekko

guanghuidatafuelx commented 1 year ago

@APMonitor Thanks for your good suggestion on using SOLVER=3 first and then SOLVER=1 next. Can I confirm with you the code like below? It looks like no need to manually code to pass the LP solution from ipopt SOLVER=3 to APMonitor SOLVER=1?

model.options.SOLVER=3
model.solve()
model.options.SOLVER=1 

model.solver_options = [
                'minlp_maximum_iterations 100', \
                # 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', \
                'minlp_print_level 8',  \
                # maximum deviation from whole number
                'minlp_integer_tol 0.05', \
                # covergence tolerance
                'minlp_gap_tol 0.001']

model.solve(disp=True)

I have posted the question in Stack Overflow here https://stackoverflow.com/questions/74353597/gekko-apmonitor-had-a-hard-time-in-converging-for-a-minlp-problem-with-linear

I haven't posted my code because it is a big file loading external data sets.

APMonitor commented 1 year ago

Thanks for asking the question on StackOverflow. I've posted a response.