# Discontinued function optimization

I am struggling with transport optimization problem, that simplified might stated as:

• Minimize the number of bananas transports to the shop in the following 5 days (transported_bananas = [n1_bananas, n2_bananas, n3_bananas, n4_bananas, n5_bananas])
• The number of bananas in the shop, at any moment, cannot exceed 1000 (max constrain)
• The number of bananas in the shop, at any moment, cannot be lower than 100 (min constrain)
• Predicted bananas bought in the shop in the 5 following days are: (predictions = [100, 500, 800, 10, 30])

I use scipy.optimize.minimize with SLSQP. I have ineq min and max constraints for each day, something like: min_bananas > transported_bananas[0, current_day] - predictions[0, current_day]and similar to max constraint.

The function which I am trying to optimize is: transport_number = sum(transported_bananas > 0)

SLSQP cannot find minimum of this function. I believe that is because only if transported bananas in given day are 0 there is no transport. It also does not matter if 1 banana is transported or 100000 bananas is transported - it is still one transport in given day. Should I look for different solver then (not based on gradient) or should I think about scaling transport number or think about making the objective function continues somehow?

• First, Is there any reason to use SLSQP instead of the MILP formulation, as @LocalSolver mentioned, for solving the problem? Second, if you could share your MP formulation it gives you more chance to deal with the community folks. – A.Omidi Feb 20 at 9:26