MATLAB: MINLP optimization using GA reaching different solutions every run

optimization

I have written a program for optimizing a set of generators. I have hourly price and cost data and need to figure out when a generator should run or just stay off. I describe the problem in more detail below. I have programed this using matlabs global optimization toolbox and the ga solver. I run the solver and each time I run the solver I get a different solution. I am thinking this is because ga is no able to properly search the solution space for an optimal solution? Is it unable to cope with the use of x_3 to turn the generator off?
The solver stops with this status:
> Optimization terminated: average change in the penalty fitness value > less than options.TolFun and constraint violation is less than > options.TolCon.
*Problem Description*
x_1 is the generator output at any one point in time and is constrained to be between a min and max capacity
x_2 is an integer variable used simply to turn the generator off completely
x_3 lastly is another integer variable used to apply a startup cost whenever the generator is switched on.
x_1, x_2 and x_3 are vectors where the index of the vector (eg. x_1(1:5) is the data for the first 5 hours)
*Objective Function (totrevenue6):*
efficiency6 = 0.2621*x_1 - 0.1229*x_1^2 + 0.2543
income6 = {-x_1*(AC_1 + FC_1 - P_1 + FC_1)}/{efficiency6}
revenue6 = - SC_1*x_3 - x_2*(income6)
**totrevenue6** = -sum(revenue6)
*Constraints:*
- min_capacity <= generator6 power (x_1) <= max_capacity
- 0 <= generator6 toggle (x_2)<= 1
- The startup constraint (x_3) is x_2-x_{2-1}<=x_3 and rearranging
-x_{2-1}+x_2-x_3<=0
- 0 <= (x_3)<= 1
So my question(s) why does ga solver reach a new solution every time I run it? How do I get the solver to solve this type of problem?
many thanks

Best Answer

The results of ga can be random, because it uses random mutation of a population of test points as part of its search.
If I take your problem statement literally, it looks like it can be simplified to a common MILP and solved with intlinprog, which should make the results more reliable. In particular, totalrevenue6 looks like it is a monotonic function of income6 which is in turn monotonic as a function of x_1. So you can optimize with respect to x1 independently, reducing the problem to an objective and constraints that are linear in the binary variables x_2 and x_3.
However, your problem description looks like it has several holes:
First, it is unclear what totalrevenue is summing over. Are you summing over hours? Over generators? Both? If x1,x2,x3 have further hidden indices over generators/hours, you should unhide them for us.
Similarly, what is x_j in the "startup constraint"? Does j=1,2,3 or is j an index for something else that's been hideen? The constraint x_2-x_1-s_1<=0 looks very strange if x_1 still refers here to generator output and x_2 still refers to the binary on/off state of the generator. Since you mention (x3), I assume you really might mean x3_j where j s an index for .... something.
Finally, it looks like you are minimizing income6, which is also strange. If I expand your expression for totalrevenue6, rearranging the minus signs, I obtain
totalrevenue6 = sum( SC_1*x_3 + x_2*(income6) )
In other words, your objective function improves if you decrease income6, which seems counter-intuitive.