From: mohamad ali on 9 Jun 2010 15:11 Hi am working on a minimization problem. T=Average network delay.......variable N=Number of nodes in the network.....fixed λi,j= Flow on the link i-j....fixed Ci,j,k = Capacity of the link i-j on radio k (or channel k)...variable C= Capacity of node...fixed M=Numbers of channels/radios per node....fixed αi,j,k= portion of traffic which is on channel k.....variable Min T=∑(i=1-->N)∑(j=1-->N)∑(k=1-->M) (αi,j,k*λi,j)/µ*Ci,j,k-αi,j,k*λi,j such that: ∑Cj,i,k+ ∑Ci,j,k<=C j=1...N,k=1.....M ∑Ci,j,k+ ∑Cp,q,k<=C j=1...N,k=1.....M ∑αi,j,k=1 k=1....M Ci,j,k>=(αi,j,k*λi,j)/µ>=0 As you can see this is a non-linear minimization problems with linear constraints(Both equality and inequality)...and the last one is a lower bound. Now what am trying to do is to get the T and Ci,j,k and αi,j,k as an output of the minimization problem. Am using fmincon to try to get a solution out of this minimization problem.I only can get the fval which is T and the X vector which is C when fixing α.I was wondering if there is a tool/way that we can get the three of them at the same time. So if anybody can pitch in any ideas it will be great...and i will update my problem later on depending on the help offered. Ali.
From: Alan Weiss on 10 Jun 2010 08:17 Unfortunately, I cannot read the problem you wrote--I guess you pasted in some characters that are not plain ASCII. From what I can understand, I believe you need to make a new variable out of all the existing variables that can change: x = [C(i,j,k) (portion of traffic on channel k]; % this is just pseudocode, you need to make one vector out of all the variables Then write your objective and constraints in terms of x and the fixed variables. Your objective seems to be T. The constraints are impossible for me to read, but I am sure you can write them in terms of x and the fixed variables. For more information on formulating problems, see http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-3.html (how to write objective fcns) and http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-11.html (how to write constraints) and http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html (how to include fixed variables) Alan Weiss MATLAB mathematical toolbox documentation On 6/9/2010 3:11 PM, mohamad ali wrote: > Hi am working on a minimization problem. > > T=Average network delay.......variable > N=Number of nodes in the network.....fixed > λi,j= Flow on the link i-j....fixed > Ci,j,k = Capacity of the link i-j on radio k (or channel k)...variable > C= Capacity of node...fixed > M=Numbers of channels/radios per node....fixed > αi,j,k= portion of traffic which is on channel k.....variable > > Min T=∑(i=1-->N)∑(j=1-->N)∑(k=1-->M) > (αi,j,k*λi,j)/µ*Ci,j,k-αi,j,k*λi,j > such that: > ∑Cj,i,k+ ∑Ci,j,k<=C j=1...N,k=1.....M > ∑Ci,j,k+ ∑Cp,q,k<=C j=1...N,k=1.....M > ∑αi,j,k=1 k=1....M > Ci,j,k>=(αi,j,k*λi,j)/µ>=0 > > > > As you can see this is a non-linear minimization problems with linear > constraints(Both equality and inequality)...and the last one is a lower > bound. > Now what am trying to do is to get the T and Ci,j,k and αi,j,k as > an output of the minimization problem. > Am using fmincon to try to get a solution out of this minimization > problem.I only can get the fval which is T and the X vector which is C > when fixing α.I was wondering if there is a tool/way that we can > get the three of them at the same time. > > So if anybody can pitch in any ideas it will be great...and i will > update my problem later on depending on the help offered. > > Ali.
From: mohamad ali on 11 Jun 2010 12:08 Small Example: First Constraint: C1+C2+C4+C5<=C.....k=1 C1+C2+C4+C5<=C.....k=2 Second Constraint: C2+C3+C6<=C..........k=1 C2+C3+C6<=C..........k=2 Third Constraint: a(1,1)+a(1,2)=1 a(2,1)+a(2,2)=1 a(3,1)+a(3,2)=1 a(4,1)+a(4,2)=1 a(5,1)+a(5,2)=1 a(6,1)+a(6,2)=1 So the above were all the equations with variables. So X=[C1,C2,C3,C4,C5,C6,a(1,1),a(1,2),a(2,1),a(2,2),a(3,1),a(3,2),a(4,1),a(4,2),a(5,1),a(5,2),a(6,1),a(6,2)] So by this A is 4*18 matrix and Aeq is 6*18 matrix and now we only have to generate these matrices in matlab and fill them out with ones and zeros and then passes them to fmincon. I already did that and am asking if my logic is correct or not.Also, a second problem that am having is with my objective function in which am getting the matlab error: "barrier "
From: Steven Lord on 11 Jun 2010 13:26 "mohamad ali " <itani.mai(a)hotmail.com> wrote in message news:hutn14$g5n$1(a)fred.mathworks.com... > Small Example: > First Constraint: > C1+C2+C4+C5<=C.....k=1 I get what you mean, right up until you add "k=1" to the end. Do you mean you want the constraint: C1+C2+C4+C5 <= C1 If so, you really want C2+C4+C5 <= 0. Or if C is some arbitrary constant, then that's somewhat confusing notation, particularly with the "k=1" statement added to the end. > C1+C2+C4+C5<=C.....k=2 > Second Constraint: > C2+C3+C6<=C..........k=1 > C2+C3+C6<=C..........k=2 > Third Constraint: > a(1,1)+a(1,2)=1 > a(2,1)+a(2,2)=1 > a(3,1)+a(3,2)=1 > a(4,1)+a(4,2)=1 > a(5,1)+a(5,2)=1 > a(6,1)+a(6,2)=1 > > So the above were all the equations with variables. > So > X=[C1,C2,C3,C4,C5,C6,a(1,1),a(1,2),a(2,1),a(2,2),a(3,1),a(3,2),a(4,1),a(4,2),a(5,1),a(5,2),a(6,1),a(6,2)] > So by this A is 4*18 matrix and Aeq is 6*18 matrix and now we only have to > generate these matrices in matlab and fill them out with ones and zeros > and then passes them to fmincon. Pretty much. Of course, you'll also need to generate B and Beq, but that shouldn't be (hopefully) that difficult. Alternately, because your equality constraints are so simple, you could make this a function of twelve variables rather than eighteen by having: X = [C; a1]; % where C is a column vector [C1; C2; C3; C4; C5; C6] and a1 is the column vector [a(1, 1); a(2, 1); ...] Then inside your objective function, compute a2 = 1-a1; and use the appropriate elements of a1 or a2 as appropriate. > I already did that and am asking if my logic is correct or not.Also, a > second problem that am having is with my objective function in which am > getting the matlab error: > "barrier " That's not a MATLAB error message. If you post the full text of the error message, the group may be able to help. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: mohamad ali on 13 Jun 2010 20:14
1) k variable is not part of the constraint...it is only used to indicate how many times i need to generate the constraint.For example if M=2 then i have to write the first constraint 2 times and the also the second constraint 2 times...so don't mind the k. 2) am interested in the way you joined my 2 parameters the C's and the a's.I was wondering if you could elaborate more in code. 3) I will write now the objective function which for me i think is the major problem. Remark: flow,xx,u,Gamma,M are all fixed variables. function fval = ObjFunctrial(X,flow,xx,u,Gamma,M) f=0; for i=1:xx for j=1:M f=f + ((flow(i)*X(M+xx))/(u*X(i)-(flow(i)*X(M+xx)))); end end fval=f/Gamma; end X=[C1,C2,C3,C4,C5,C6,a(1,1),a(1,2),a(2,1),a(2,2),a(3,1),a(3,2),a(4,1),a(4,2),a(5,1),a(5,2),a(6,1),a(6,2)] xx=6 in this case Note: I need to get every variable and also f.For example, i want to get the value of C1 which is X(1) and a(1,1) and a(1,2) in which a(1,1) is C(1+xx) and a(2,2) is C(2+xx) and then C2 and a(2,1) a(2,2)..and so on and on until i get all 18 variables and then use them to calculate f. Am getting the following error message: ??? Error using ==> barrier at 14 Objective function is undefined at initial point. Fmincon cannot continue. 4) I have also one last problem am facing which is the lower bound.I have to put for example C(1)>=[flow(1)*a(1,1)]/u; but for all variables Translated to X: X(i)>=[flow(i)*X(i+xx)]/u; The problem is that X vector is both an output and input at the same time..so how can i do that in coding. So those were responses and my new questions and I hope you could help out,, Ali |