How to write an objective function which is equal to a specific value in optimization toolbox (especially for fmincon or genetic algorithm)
Show older comments
I have a problem to find appropriate coefficient with using fmincon function in Matlab.
I have to constraints in that problem and my objective function is minimize error rate (trying to find bitError = 0)
I wrote that code to find it:
-------------------------------
txD = randsrc(2,1,[-1:2:1]);
lb = ones(8,1);
ub = 2*ones(8,1);
A = cH;
signTxD = -1*txD;
tempTxD = txD;
tempTxD(txD == 1) = 1.6;
tempTxD(txD ==-1) = 1.4;
thresholdUsers(1,:) = 1.5*Ptx*ones(1,8)*cH';
for userK = 1:numUser
A(userK,:) = signTxD(userK).*A(userK,:);
b(userK,1) = tempTxD(userK)*Ptx*ones(1,8)*cH(userK,:)';
end
options = optimoptions(@fmincon,'Display','off');
[x,fval] = fmincon(@(x)fMinObjFun(x,Ptx,cH,thresholdUsers,txD),...
startPoint,A,b,[],[],lb,ub,[],options)
---------------
function bEobj = fMinObjFun(x,Ptx,cH,thresholdUsers,txD)
recD = x'*Ptx*cH';
rcvr = recoverData(thresholdUsers,recD); % decides if threshold>rec = 1, else =-1
diffVec = txD - rcvr;
bEobj = sum(abs(diffVec));
---------------
I tried to find possible coefficients (x values) from all possible outcomes for x.
Unfortunately, when I generated possible x values, [1:0.1:2], the combination matrix exceeds 200 million.
That's why I would like to use one of the matlab searching algorithms to find out coefficients which has 0 bit error rate.
The code above can not find appropriate x values for my objective (bitError = 0).
If you have any ideas how I can reconstruct my objective function, please share with me.
Thanks in advance.
2 Comments
Your objective function is highly non-differentiable, violating the assumptions of fmincon.
What are the dimensions of the different variables, e.g., recD, rcvr, and diffVec? Even though there may be 200 million combinations for x, it looks like rcvr and diffVec are always binary. There are therefore fewer combinations of those to search over. Once you find the ones that give you zero bit error, you can then turn to the problem of finding the corresponding x.
Answers (1)
The recD, rcvr and diffVec vectors have numUser elements (2,4,6..).
Which means that there are at most 2^numUser combinations of values that rcvr can have. Since the bit error depends on x only through rcvr, you can search through all combinations of rcvr values to see which achieves zero bit error. A solution for x is then a member of the polyhedron with inequalities,
(D*cH'*Ptx')*x <= (D*thresholds)
8 Comments
Tezcan
on 5 Apr 2015
According to your comment, D is depended on x
No, the rcvr in my last comment is the one resulting from a combinatoric search over the discrete space of vectors with elements -1 and +1. It doesn't originate from a search over x at all. To clarify, denote rcvrOpt as the combination of -1s and +1s that gives zero bit error. Then revise my last comment as
D=diag(-rcvrOpt);
(D*cH'*Ptx')*x <= (D*thresholds);
I'm assuming you know a priori that a zero bit error is achievable by some x.
Should I use the lcon2vert function in my objective function?
No. You should abandon fmincon altogether. Your problem is not differentiable and therefore not in the class of problems that fmincon handles, see also my 1st Comment.
Tezcan
on 5 Apr 2015
Matt J
on 5 Apr 2015
You must download the entire package.
Tezcan
on 6 Apr 2015
You need to write your lb,ub bounds
lb = ones(8,1);
ub = 2*ones(8,1);
as inequalities and add those to the system.
Tezcan
on 6 Apr 2015
You express them through the inequality matrix/vector data arguments
A*x<=b
just like all the other inequalities. You add rows to the existing data A=(D*cH'*Ptx') , b=(D*thresholds) so that the bounds are expressed in there as well.
Categories
Find more on Data Import in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!