I have an optimization problem in which some inequalities constraints can either be 0 or greater than a certain value. For example, in the code below, qtde and c1 are lists and pp is a 2d numpy array.
import numpy as np
from gekko import GEKKO
qtde = [7, 2, 2, 12, 2, 7, 1.5, 8, 4, 16, 2, 1, 3, 0.2, 3, 1, 1, 10, 8, 5, 3, 2.5, 5, 2.5, 10, 3, 1, 6, 12, 2, 6, 1, 4, 1, 2, 10, 1, 1, 1, 1]
c1 = [26.0, 150.0, 300.0, 110.0, 400.0, 500.0, 200.0, 200.0, 27.0, 150.0, 50.0, 200.0, 75.0, 0.0, 250.0, 22.8, 300.0, 22.8, 22.8, 150.0, 300.0, 150.0, 100.0, 100.0, 1000.0, 150.0, 150.0, 200.0, 31.2, 100.0, 100.0, 50.0, 23.0, 300.0, 200.0, 300.0, 0.0, 300.0, 30.0, 26.0, 300.0, 300.0, 250.0, 100.0, 100.0, 200.0, 400.0, 21.2, 200.0, 500.0, 0.0]
mm = [[4,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,5,0,2,0,0,0,7,0,0,0,6,0,0,0,8,0,0,0,0,0,0,0,0,0,3,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,10,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,0,0,0,0,0,0,17,15,0,0,16,0,0,18,0,0,0,0,0,0,0,0,0,0],
[26,0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0,0,21,0,0,0,25,0,0,0,23,0,0,0,22,0,0,0,0,0,0,0,0,0,24,0,20,0,0,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,30,0,0,31,0,0,0,0,0,0,0,32,0,0,33,0,28,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,40,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0,0,0,0,0,0,0,100,0,0,0,0,0,99,0,98,0,0,0,103,0,0,0,101,0,0,0,102,0,0,0,0,0,0,0,0,0,0,0,97,0,0,0,0,0,0,0,0],
[112,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,110,0,107,0,0,0,111,0,0,0,109,0,0,0,113,0,0,0,0,0,0,0,0,0,106,0,105,0,0,0,0,0,0,0,0],
[114,0,0,0,0,0,0,0,0,0,116,0,0,0,0,0,117,0,119,0,0,0,115,0,0,0,118,0,0,0,120,0,0,0,0,0,0,0,0,0,121,0,122,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,123,0,0,0,0,0,0,0,0],
[0,129,0,0,0,0,126,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,127,125,0,0,0,0,0,0,0,0,0,0,130,0,0,0,0,0,124,0,131,0,0,0],
[0,133,0,0,0,0,136,0,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,0,0,0,0,0,0,0,0,0,0,0,0,140,0,0,0,0,0,0,0,0,0,0,0,0,0,141],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,142,0,143,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,0,0,0,150,0,146,0,149,0,0,0,0,0,0,152,0,0,0,145,0,0,0,0,147,0,0,151,0,0,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0,0,0,0,0,0,0,0,0,0,188,0],
[0,0,193,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0],
[0,0,197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,196,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,195,0,0,194,0,0,0,0],
[0,0,0,0,0,0,0,0,0,199,0,0,0,0,201,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,198,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,203,0,0,0,0,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,202,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
mm = np.array(mm)
#
pp = [[5.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,7.90,0.00,0.00,0.00,0.00,0.00,5.49,0.00,2.89,0.00,0.00,0.00,5.98,0.00,0.00,0.00,5.94,0.00,0.00,0.00,6.21,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.55,0.00,2.89,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,5.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.61,0.00,0.00,0.00,5.80,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.15,0.00,3.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,15.95,0.00,0.00,0.00,0.00,0.00,0.00,14.00,11.95,0.00,0.00,12.36,0.00,0.00,14.18,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[3.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.20,0.00,0.00,0.00,2.80,0.00,0.00,0.00,2.29,0.00,0.00,0.00,2.27,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.61,0.00,2.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[3.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.76,0.00,0.00,0.00,0.00,0.00,0.00,0.00,5.70,0.00,0.00,6.47,0.00,0.00,0.00,0.00,0.00,0.00,0.00,7.47,0.00,0.00,8.51,0.00,3.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.50,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.52,0.00,0.00,0.00,9.10,0.00,0.00,0.00,9.57,0.00,0.00,0.00,9.62,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.10,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[6.75,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.50,0.00,0.00,0.00,0.00,0.00,7.98,0.00,6.99,0.00,0.00,0.00,11.05,0.00,0.00,0.00,8.55,0.00,0.00,0.00,8.88,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,8.27,0.00,6.75,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,11.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.95,0.00,0.00,0.00,9.75,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.63,0.00,9.16,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.69,0.00,0.00,0.00,1.98,0.00,0.00,0.00,1.77,0.00,0.00,0.00,1.96,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.69,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[10.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,7.10,0.00,0.00,0.00,0.00,0.00,1.59,0.00,0.00,0.00,0.00,0.00,1.95,0.00,0.00,0.00,1.74,0.00,0.00,0.00,2.09,0.00,0.00,0.00,0.00,0.00,0.00,6.43,0.00,0.00,1.70,0.00,2.83,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.93,0.00,9.93,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,18.40,0.00,0.00,0.00,0.00,0.00,14.49,0.00,0.00,0.00,0.00,0.00,12.89,0.00,0.00,0.00,14.36,0.00,0.00,0.00,13.76,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,13.48,0.00,11.91,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,9.39,0.00,0.00,0.00,7.97,0.00,0.00,0.00,9.57,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,10.24,0.00,9.49,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,33.35,0.00,0.00,0.00,14.80,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,18.00,0.00,72.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[5.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,6.00,0.00,0.00,0.00,0.00,0.00,5.78,0.00,4.50,0.00,0.00,0.00,3.90,0.00,0.00,0.00,4.06,0.00,0.00,0.00,6.46,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.55,0.00,3.55,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[4.50,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.60,0.00,0.00,0.00,0.00,0.00,3.19,0.00,2.69,0.00,0.00,0.00,4.12,0.00,0.00,0.00,3.75,0.00,0.00,0.00,4.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.69,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[5.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.80,0.00,0.00,0.00,0.00,0.00,4.65,0.00,3.69,0.00,0.00,0.00,5.42,0.00,0.00,0.00,4.50,0.00,0.00,0.00,6.40,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,3.55,0.00,3.55,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[4.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,5.40,0.00,0.00,0.00,0.00,0.00,5.49,0.00,6.60,0.00,0.00,0.00,4.33,0.00,0.00,0.00,6.38,0.00,0.00,0.00,6.92,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,7.09,0.00,8.68,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,8.68,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,18.99,0.00,0.00,0.00,0.00,16.98,0.00,0.00,0.00,0.00,0.00,0.00,17.80,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,17.20,16.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,28.58,0.00,0.00,0.00,0.00,0.00,13.99,0.00,30.45,0.00,0.00,0.00],
[0.00,9.49,0.00,0.00,0.00,0.00,34.98,0.00,0.00,0.00,0.00,0.00,0.00,18.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,8.77,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,15.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,47.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,38.39,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,89.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,91.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,92.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,66.89,0.00,79.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,27.30,0.00,0.00,0.00,36.90,0.00,29.50,0.00,36.00,0.00,0.00,0.00,0.00,0.00,0.00,49.90,0.00,0.00,0.00,28.90,0.00,0.00,0.00,0.00,31.99,0.00,0.00,42.00,0.00,0.00,0.00,0.00,0.00,33.50],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,65.00,0.00,0.00,0.00,0.00,0.00,23.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,12.89,0.00,0.00,0.00,13.99,0.00,0.00,13.90,0.00,0.00,0.00,14.32,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,16.50,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,15.57,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,36.75,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,58.73,0.00,0.00,53.43,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,51.85,0.00],
[0.00,0.00,5.39,0.00,0.00,0.00,0.00,0.00,0.00,6.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,12.36,14.63,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,18.76,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,12.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,86.00,0.00,0.00,0.00,0.00,0.00,0.00,89.90,97.30,0.00,0.00,81.60,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,96.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,89.00,83.77,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,64.28,0.00,0.00,49.46,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,52.34,0.00],
[0.00,0.00,0.00,0.00,79.90,89.00,0.00,124.00,0.00,0.00,0.00,85.00,104.47,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,67.20,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,91.00,91.11,0.00,0.00,73.61,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,81.50,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,80.60,0.00],
[0.00,0.00,2.47,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.44,0.00,0.00,0.00,0.00],
[0.00,0.00,28.44,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,15.90,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,15.10,0.00,0.00,13.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,22.00,0.00,0.00,0.00,0.00,31.92,0.00,0.00,0.00,0.00,0.00,0.00,0.00,28.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,22.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,8.55,0.00,0.00,0.00,0.00,62.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,8.30,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00],
[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,62.70,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00]]
pp = np.array(pp)
#c1 = [26.0, 150.0, 300.0, 110.0, 400.0, 500.0, 200.0, 200.0, 27.0, 150.0, 50.0, 200.0, 75.0, 0.0, 250.0, 22.8, 300.0, 22.8, 22.8, 150.0, 300.0, 150.0, 100.0, 100.0, 1000.0, 150.0, 150.0, 200.0, 31.2, 100.0, 100.0, 50.0, 23.0, 300.0, 200.0, 300.0, 0.0, 300.0, 30.0, 26.0, 300.0, 300.0, 250.0, 100.0, 100.0, 200.0, 400.0, 21.2, 200.0, 500.0, 0.0]
m = GEKKO()
ni = 40
nj = 51
x = [[m.Var(lb=0,integer=True) for j in range(nj)] for i in range(ni)]
s = 0
expr = []
for i in range(ni):
for j in range(nj):
s += x[i][j]
for i in range(ni):
expr.append(sum(x[i]))
for i in range(ni):
for j in range(nj):
if mm[i][j] == 0:
m.Equation(x[i][j] == 0)
for i in range(ni):
m.Equation(sum([x[i][j] for j in range(nj)]) >= qtde[i])
b = m.Array(m.Var,nj,integer=True,lb=0,ub=1)
iv = [None]*nj
for j in range(nj):
iv[j] = m.sum([pp[i][j]*x[i][j] for i in range(ni)])
m.Equation(iv[j] >= b[j]*c1[j])
m.Equation((1 - b[j])*iv[j] == 0)
m.Obj(m.sum(expr))
m.options.SOLVER=1 # switch to APOPT
m.solver_options = ['minlp_gap_tol 1.0e-1',\
'minlp_maximum_iterations 10000',\
'minlp_max_iter_with_int_sol 1000',\
'minlp_branch_method 1',\
'minlp_integer_leaves 2']
m.solve()
Edit: I have changed the writing of the last constraint as suggested by John Hedengren (bellow). However, with the insertion of the binary variable, the code now returns an error before starting any iterations. How can this be prevented?
You can use a binary variable (0=equipment off, 1=equipment on and above threshold) and equation as:
b = m.Array(m.Var,nj,integer=True,lb=0,ub=1)
iv = [None]*nj
for j in range(nj):
iv[j] = m.sum([pp[i][j]*x[i][j] for i in range(ni)])
m.Equation(iv[j] >= b[j]*c1[j])
m.Equation((1-b[j])*iv[j] <= 0)
m.options.SOLVER = 1 # Change to MINLP solver
You can split out the summation into an intermediate variable iv because it is used in two equations. Another recommendation is to use m.sum() instead of sum. Using the Gekko summation is typically faster. There are also other ways to pose the problem but this may be the most reliable. I can't verify this solution because your script is missing some inputs. It helps on future posts to reduce the problem to a Minimal and Reproducible example so that solutions can be verified. There is additional information on logical conditions in optimization problems.
Response to Edit
The MINLP does not converge quickly because there are nj x ni = 2040 binary variables. That is 2^2040 potential solutions. You can adjust solver settings to help it find at least one feasible solution.
m.options.SOLVER=3
m.solve() # sometimes it helps to solve with IPOPT first
m.options.SOLVER=1 # switch to APOPT
m.solver_options = ['minlp_gap_tol 1.0e-2',\
'minlp_maximum_iterations 10000',\
'minlp_max_iter_with_int_sol 500',\
'minlp_branch_method 1',\
'minlp_integer_leaves 2']
m.solve()
There is additional description on the solver options on the APOPT website.
Response to Edit
The error on the first MINLP iteration is because the problem is not feasible. If you switch to solver option minlp_as_nlp 1 then you can see the first NLP problem fail to converge. You can also see this with the IPOPT solver if you switch to m.options.SOLVER=3.
EXIT: Converged to a point of local infeasibility.
Problem may be infeasible.
If you solve locally with m=GEKKO(remote=False) and open the run folder before the solve command with m.open_folder() then you can see the infeasibilities.txt file that will help you identify the infeasible equation. I suspect that the infeasibility is because of the equations m.Equation(m.sum([x[i][j] for j in range(nj)]) >= qtde[i]) and m.Equation(x[i][j] == 0). You can also try to identify an infeasible problem with m.options.COLDSTART=2. There is additional help on troubleshooting applications in exercise 18 in the Gekko tutorials.