I'd like to be able to find the maximum value that my Capex function (see below) generates. This is a fairly simple function so I could just add it up but I have more complex functions of a similar form that I'll need to maximize.
Capex[romSize_, CCSPsize_, washRate_, miningRate_] :=
Module[{val, rom = romSize, CCSP = CCSPsize, wash = washRate},
val = 0;
Which[CCSP > 500, val = val - 100];
Which[rom >= 200 && rom < 300, val = val - 5, rom >= 300,
val = val - 10];
Which[wash >= 1300 && wash < 1500, val = val - 10, wash >= 1500,
val = val - 20];
Which[miningRate >= 5.5 && miningRate < 5.7, val = val - 10,
miningRate >= 5.7, val = val - 20];
Return[val]
];
The problem I have is that because it contains Which statements the Maximize function doesn't seem to work. I could spam the Capex function with values in the domain and pick the largest value but I was hoping Mathematica had some functionality to make it a little easier, kind of like Goal Seek in Excel.
An example of a simple maximize call would be
Maximize[{Capex[x, 600, 1500, 6], 120 <= x <= 300}, {x}]
The max value of -240 is correct but x=300 is not
Maximize[]
; have a look atPlot[Capex[x, 600, 1500, 6], {x, 120, 300}]
to see why. $\endgroup$