GLPK is able to handle the integrality constraints that you defined, however it cannot handle the non-linear objective that you want.
As expressed by the error message, nonlinear objectives must be entered with the other macro.
Any reason to that objective?
You have a few options:
Easier to optimize:
- change you objective function to something linear to keep using GLPK, you probably can model a absolute value related objective using linear programming techniques.
like minimizing the largest absolute distance between two jars. or even minimize the number of marbles in the jar with most marbles…
Harder to optimize:
-
change the solver to something that handles non-linear and integer (this class of problems is extremely hard to solve to optimality), some options are: Alpine.jl, Juniper.jl, Knitro, SCIP, Couenne (via GitHub - jump-dev/AmplNLWriter.jl: Julia interface to AMPL-enabled solvers)
-
you might be able to obtain a reformulation or an approximation of your objective using quadratic terms so you can use Gurobi, Xpress or CPLEX
-
you might be able to obtain a reformulation or an approximation of your objective using cones so you can use Mosek
There are certainly options and solvers that I am missing…