I have a simple integer programing model, and the intlinprog() command finds the optimal solution, but ga() does not.
The problem is very simple: max TP*X subject to cost*X <=budget and X is a binary vector of 626 element.
If I run it as a linear programming , it gets me the optimal solution:
[x1,fval1,flag1,output1]=intlinprog(-1*TP,1:626,Cost',budget,[],[],zeros(626),ones(626))
This results in fval1=-1002.5 and flag1=1 optimal solution
at the same time if I run this:
[x4,fval4,flag4,output4]=ga(@(X)(-1*X*TP),626,Cost',budget,[],[],zeros(1,626),ones(1,626),[],1:626)
It result is fval4=-460 flag4=1
Obviously this is wrong and the solution is far cry from the actual solution.
Best Answer