I have a machine with following characteristics:
(1) Every time machine runs there is a fixed charge of $50
(2) Once machine runs it must run for 4 hours at least. Machine can hence have multiple starts and stops. Machine can run entire time in a given period if it is profitable to do so. The given period can be hours, days or months, etc.
(3) When the machine is running it is producing revenue as following for 24 hours period:[5, 10, -5, 10, -6, -20, 5, 7, 5, 10, -5, 10, -6, -20, 5, 7, 5, 10, -5, 10, -6, -20, 5, 7] . Negative means if machine runs it will loose $$
(4) Revenue for next day is same as above. Machine can start at 11 PM and run for 4 hours i.e. until 3 am next day or longer.
(5) It might be economical to run the machine at negative revenue until next start instead of stopping and paying the start charge
I don't want a for loop but some optimization algorithm.