How to write an objective function which is equal to a specific value in optimization toolbox (especially for fmincon or genetic algorithm)

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.
Thanks for your reply. The recD, rcvr and diffVec vectors have numUser elements (2,4,6..).
Actually, the problem is finding the x values that has zero bit error rate. recD and rcvr are -1 or 1 (for ex. rcvr=[-1;1] for numUser=2 and recD is in [0,x*Ptx*HH'] interval).
The 200 million combination is just I try to find it myself without using fmincon.
I know my objective function is non-differentiable that's why I am looking for suggestions to use another searching algorithm or how to write that objective in a differentiable form.

Sign in to comment.

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)
where D=diag(-rcvr). You could use LCON2VERT ( Download ) to find the vertices of this polyhedron

8 Comments

According to your comment, D is depended on x (rcvr depends on recD and recD = x'Ptx*cH'). Should I use the lcon2vert function in my objective function? Also, I have an error message when I try to find V:
recD = x'*Ptx*cH';
rcvr = recoverData(thresholdUsers,recD);
D = diag(-rcvr);
A = D*cH'*Ptx;
b = D*thresholdUsers;
[V,nr,nre]=lcon2vert(A,b,[],[],TOL)
Undefined function 'vert2lcon' for input arguments of type 'double'.
Error in lcon2vert>con2vert (line 305) [aa,bb,aaeq,bbeq]=vert2lcon(A,TOL);
Error in lcon2vert (line 234) [Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);
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.
I still get the same error
Undefined function 'vert2lcon' for input arguments of type 'double'.
Error in lcon2vert>con2vert (line 305)
[aa,bb,aaeq,bbeq]=vert2lcon(A,TOL);
Error in lcon2vert (line 234)
[Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);
Now I am getting that error message. I try to write upper and lower bounds but there are no any explanation on 'checkbounds'.
Error using lcon2vert>con2vert (line 308)
Non-bounding constraints detected. (Consider box constraints on variables.)
Error in lcon2vert (line 234) [Zt,nr]=con2vert(AAA,bbb,TOL,checkbounds);
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.
But my question is how to write them to the lcon2ver function as an input.
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.

Sign in to comment.

Asked:

on 5 Apr 2015

Edited:

on 6 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!