I am testing the m.if3 function in gekko by using conditional statements of if-else but I get two different outputs. The optimal number i get from below code is 12. I plug that in the next code with if-else statement to ensure that the cost matches up but it does not. Am I using if3/if2 incorrectly? The rate is 0.1 for the first 5 days and it switches to 0.3 for the remaining 45 days.
I get different outputs even though I am doing the same thing in both of them.
I tried everything from using if-else statements to using if2 statements.
The
if2orif3function isn't needed because the switching argumentduration-5is a constant value that is not a function of a Gekko variable. Just like the validation script, the two segments can be calculated separately and added together to get a total cost and patient count.The optimal solution is:
The solution validation agrees with this answer: