From: SARVANI NADIMINTY on
I used 'fmincon' for optimization with more than one non linear constraints.. It s working but I am getting a e+034 factor extra for my value which i should not get . All other values are correct whatever I have given..I have given the lower bound as 1 and upper bound as 2..But there is always this factor coming in my answer.
I am doing optimization for a 96 variable problem.
So I tried reducing my problem and reduced them to 12 variables.Still I a facing this e+034 problem.
From: James Allison on
I'm glad to hear you figured out how to implement multiple nonlinear
constraints. It sounds like there may be a problem with the formulation
you are using. Perhaps it is unbounded or otherwise ill-posed. Would it
be possible for you to post the simplified 12 variable problem? Someone
might be able to help if you can.

-James

SARVANI NADIMINTY wrote:
> I used 'fmincon' for optimization with more than one non linear
> constraints.. It s working but I am getting a e+034 factor extra for my
> value which i should not get . All other values are correct whatever I
> have given..I have given the lower bound as 1 and upper bound as 2..But
> there is always this factor coming in my answer.
> I am doing optimization for a 96 variable problem.
> So I tried reducing my problem and reduced them to 12 variables.Still I
> a facing this e+034 problem.
From: SARVANI NADIMINTY on
James Allison <james.allison(a)mathworks.com> wrote in message <hpl8ts$2pd$2(a)fred.mathworks.com>...
> I'm glad to hear you figured out how to implement multiple nonlinear
> constraints. It sounds like there may be a problem with the formulation
> you are using. Perhaps it is unbounded or otherwise ill-posed. Would it
> be possible for you to post the simplified 12 variable problem? Someone
> might be able to help if you can.
>
> -James
>
> SARVANI NADIMINTY wrote:
> > I used 'fmincon' for optimization with more than one non linear
> > constraints.. It s working but I am getting a e+034 factor extra for my
> > value which i should not get . All other values are correct whatever I
> > have given..I have given the lower bound as 1 and upper bound as 2..But
> > there is always this factor coming in my answer.
> > I am doing optimization for a 96 variable problem.
> > So I tried reducing my problem and reduced them to 12 variables.Still I
> > a facing this e+034 problem.
Here is the problem:
this is the main function to be minimized:
function f=myfun1(a)
f=sum(sum(a.*a));
'a' is a 4by3 matrix in case of 12 variables and a 16by6 matrix in case of 96 variables.

here is the constraint function in case of 96 variables.

function [c,ceq]=mycon(a)
p=[ 0.4 0.3 0.5 0.2 0.03 0.17 0.1 0.04 0.06 0.08 0.05 0.09 0.02 0.12 0.01 0.13];
users=6;
for i=1:16
t(i,1:users)= sqrt(p(i)/2)*(randn(1,users)+j*randn(1,users));
end
n=16;
walsh=hadamard(n);
walsh1=walsh(1:n,1:users);
m=a.*walsh1.*t;
mh= m';
s=inv(m*mh+0.25*eye(n));
c(1)= 0.9-[mh(1,:)*(s)*m(:,1)];
c(2)= 0.8-[mh(2,:)*(s)*m(:,2)];
c(3)= 0.7-[mh(3,:)*(s)*m(:,3)];
c(4)= 0.4-[mh(4,:)*(s)*m(:,4)];
c(5)= 0.5-[mh(5,:)*(s)*m(:,5)];
c(6)= 0.3-[mh(6,:)*(s)*m(:,6)];
ceq=[];

%for a 12 variable matrix there are only 3 constraints i.e. upto c(3)

Here is my fmincon prog.,(the main prog to be run)

clc;
close all;
clear all;
x0=ones(16,6);
Aeq =[];
beq =[];
A =[];
b = [];
% lb=[];
% ub=[];
lb=1;
ub=2;
options=optimset('maxfunevals',12000,'plotfcn',@optimplotfval,'display','iter','largescale','off');
[x,fval,exitflag,output,lambda]=fmincon(@myfun1,x0,A,b,Aeq,beq,lb,ub,@mycon,options)
% m=x.*

please tell me if anyone knows
From: Alan Weiss on
SARVANI NADIMINTY wrote:
> James Allison <james.allison(a)mathworks.com> wrote in message
> <hpl8ts$2pd$2(a)fred.mathworks.com>...
>> I'm glad to hear you figured out how to implement multiple nonlinear
>> constraints. It sounds like there may be a problem with the
>> formulation you are using. Perhaps it is unbounded or otherwise
>> ill-posed. Would it be possible for you to post the simplified 12
>> variable problem? Someone might be able to help if you can.
>>
>> -James
>>
>> SARVANI NADIMINTY wrote:
>> > I used 'fmincon' for optimization with more than one non linear >
>> constraints.. It s working but I am getting a e+034 factor extra for
>> my > value which i should not get . All other values are correct
>> whatever I > have given..I have given the lower bound as 1 and upper
>> bound as 2..But > there is always this factor coming in my answer.
>> > I am doing optimization for a 96 variable problem.
>> > So I tried reducing my problem and reduced them to 12
>> variables.Still I > a facing this e+034 problem.
> Here is the problem:
> this is the main function to be minimized:
> function f=myfun1(a)
> f=sum(sum(a.*a));
> 'a' is a 4by3 matrix in case of 12 variables and a 16by6 matrix in case
> of 96 variables.
>
> here is the constraint function in case of 96 variables.
>
> function [c,ceq]=mycon(a)
> p=[ 0.4 0.3 0.5 0.2 0.03 0.17 0.1 0.04 0.06 0.08 0.05 0.09 0.02 0.12
> 0.01 0.13];
> users=6;
> for i=1:16
> t(i,1:users)= sqrt(p(i)/2)*(randn(1,users)+j*randn(1,users));
> end
> n=16;
> walsh=hadamard(n);
> walsh1=walsh(1:n,1:users);
> m=a.*walsh1.*t;
> mh= m';
> s=inv(m*mh+0.25*eye(n));
> c(1)= 0.9-[mh(1,:)*(s)*m(:,1)];
> c(2)= 0.8-[mh(2,:)*(s)*m(:,2)];
> c(3)= 0.7-[mh(3,:)*(s)*m(:,3)];
> c(4)= 0.4-[mh(4,:)*(s)*m(:,4)];
> c(5)= 0.5-[mh(5,:)*(s)*m(:,5)];
> c(6)= 0.3-[mh(6,:)*(s)*m(:,6)];
> ceq=[];
>
> %for a 12 variable matrix there are only 3 constraints i.e. upto c(3)
>
> Here is my fmincon prog.,(the main prog to be run)
>
> clc;
> close all;
> clear all;
> x0=ones(16,6);
> Aeq =[];
> beq =[];
> A =[];
> b = [];
> % lb=[];
> % ub=[];
> lb=1;
> ub=2;
> options=optimset('maxfunevals',12000,'plotfcn',@optimplotfval,'display','iter','largescale','off');
>
> [x,fval,exitflag,output,lambda]=fmincon(@myfun1,x0,A,b,Aeq,beq,lb,ub,@mycon,options)
>
> % m=x.*
>
> please tell me if anyone knows

I see several potential problems with your formulation:

1. You use complex numbers in your computation of nonlinear constraints.
You have to use real numbers only in Optimization Toolbox functions.
Separate your complex variables into real and imaginary parts, and write
your constraints in terms of real variables only. This could be the
cause of your main problem.

To see if this is really a problem, turn on the FunValCheck option.

2. You use random numbers (t) in your constraint functions. Don't do it!
If you must have random numbers, make a matrix of t out of one call to
randn, and reuse this exact same t every time, for example by making t a
fixed variable in a function handle.

3. I'm not sure which version of MATLAB you run, but the syntax for
choosing the algorithm has not been setting 'LargeScale' to 'off' for
several releases. This is not a major problem.

Alan Weiss
MATLAB mathematical toolbox documentation
From: SARVANI NADIMINTY on
Alan Weiss <aweiss(a)mathworks.com> wrote in message <hpn5dj$9ia$1(a)fred.mathworks.com>...
> SARVANI NADIMINTY wrote:
> > James Allison <james.allison(a)mathworks.com> wrote in message
> > <hpl8ts$2pd$2(a)fred.mathworks.com>...
> >> I'm glad to hear you figured out how to implement multiple nonlinear
> >> constraints. It sounds like there may be a problem with the
> >> formulation you are using. Perhaps it is unbounded or otherwise
> >> ill-posed. Would it be possible for you to post the simplified 12
> >> variable problem? Someone might be able to help if you can.
> >>
> >> -James
> >>
> >> SARVANI NADIMINTY wrote:
> >> > I used 'fmincon' for optimization with more than one non linear >
> >> constraints.. It s working but I am getting a e+034 factor extra for
> >> my > value which i should not get . All other values are correct
> >> whatever I > have given..I have given the lower bound as 1 and upper
> >> bound as 2..But > there is always this factor coming in my answer.
> >> > I am doing optimization for a 96 variable problem.
> >> > So I tried reducing my problem and reduced them to 12
> >> variables.Still I > a facing this e+034 problem.
> > Here is the problem:
> > this is the main function to be minimized:
> > function f=myfun1(a)
> > f=sum(sum(a.*a));
> > 'a' is a 4by3 matrix in case of 12 variables and a 16by6 matrix in case
> > of 96 variables.
> >
> > here is the constraint function in case of 96 variables.
> >
> > function [c,ceq]=mycon(a)
> > p=[ 0.4 0.3 0.5 0.2 0.03 0.17 0.1 0.04 0.06 0.08 0.05 0.09 0.02 0.12
> > 0.01 0.13];
> > users=6;
> > for i=1:16
> > t(i,1:users)= sqrt(p(i)/2)*(randn(1,users)+j*randn(1,users));
> > end
> > n=16;
> > walsh=hadamard(n);
> > walsh1=walsh(1:n,1:users);
> > m=a.*walsh1.*t;
> > mh= m';
> > s=inv(m*mh+0.25*eye(n));
> > c(1)= 0.9-[mh(1,:)*(s)*m(:,1)];
> > c(2)= 0.8-[mh(2,:)*(s)*m(:,2)];
> > c(3)= 0.7-[mh(3,:)*(s)*m(:,3)];
> > c(4)= 0.4-[mh(4,:)*(s)*m(:,4)];
> > c(5)= 0.5-[mh(5,:)*(s)*m(:,5)];
> > c(6)= 0.3-[mh(6,:)*(s)*m(:,6)];
> > ceq=[];
> >
> > %for a 12 variable matrix there are only 3 constraints i.e. upto c(3)
> >
> > Here is my fmincon prog.,(the main prog to be run)
> >
> > clc;
> > close all;
> > clear all;
> > x0=ones(16,6);
> > Aeq =[];
> > beq =[];
> > A =[];
> > b = [];
> > % lb=[];
> > % ub=[];
> > lb=1;
> > ub=2;
> > options=optimset('maxfunevals',12000,'plotfcn',@optimplotfval,'display','iter','largescale','off');
> >
> > [x,fval,exitflag,output,lambda]=fmincon(@myfun1,x0,A,b,Aeq,beq,lb,ub,@mycon,options)
> >
> > % m=x.*
> >
> > please tell me if anyone knows
>
> I see several potential problems with your formulation:
>
> 1. You use complex numbers in your computation of nonlinear constraints.
> You have to use real numbers only in Optimization Toolbox functions.
> Separate your complex variables into real and imaginary parts, and write
> your constraints in terms of real variables only. This could be the
> cause of your main problem.
>
> To see if this is really a problem, turn on the FunValCheck option.
>
> 2. You use random numbers (t) in your constraint functions. Don't do it!
> If you must have random numbers, make a matrix of t out of one call to
> randn, and reuse this exact same t every time, for example by making t a
> fixed variable in a function handle.
>
> 3. I'm not sure which version of MATLAB you run, but the syntax for
> choosing the algorithm has not been setting 'LargeScale' to 'off' for
> several releases. This is not a major problem.
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
Thanks a thousand times for your reply..It has been very useful.