Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Optimization Problem, Linear Equations with multiple constraints

Subject: Optimization Problem, Linear Equations with multiple constraints

From: EE Student

Date: 13 Jun, 2010 21:05:04

Message: 1 of 7

Hey guys, I have a problem I have been working on for a bit and seem to be stuck with. Hopefully I can describe the problem well enough so that everyone understands what I am trying to do. Just so everyone knows, this is not a homework or school related problem. What I have is a matrix, lets call it LD, which has size = [365 24]. Yep, you guessed it, its 365 days worth of hourly data. I also have 3 sets of monthly target data. The target data described the hourly maximum, hourly minimum, and total energy for each month for 3 regions. My goal is to take my known matrix LD, and scale it such that I create 3 new matrices, call the P1, P2, and P3 such that the targets for each month, for each region are met. My initial approach is to scale LD on a monthly basis for each of the target regions to create 3 new matrices that meet the monthly max and min target, then to ajust these new
matrices to match the monthly energy targets.

This is not my code but an attempt to explain my goals using equations, and also note that siince I have monthly target numbers each of these in effect will represent a months worth of hourly data and the process will be repeated 12 times.

LD = P1 + P2 + P3;
P1 = LD * S1 + E*Y1
P2 = LD * S2 + E*Y2
P3 = LD * S3 + E*Y3

Where

S1,S2,S3 are the scale factors to meet the monthly max and min targets.

X1 = LD*S1
X2 = LD*S2
X3 = LD*S3

X1,X2,X3 are known ouputs of the scaling portion of the algorithm which has been accomplished. Therefore in the following equations X1,X2,X3 and LD are all known matrices with size = [number_of _days_in_month hour] and the minimum and maximum targets are exactly met by the respective X matrices for each region so these two hours in each of the X matices cannot be adjusted further.

LD = X1 + X2 + X3 + E
P1 = X1 + E*Y1
P2 = X2 + E*Y2
P3 = X3 + E*Y3

E = LD - sum(X1+X2+X3)

sum(P1) = monthly energy target for region 1
sum(P2) = monthly energy target for region 2
sum(P3) = monthly energy target for region 3

P1(day,hour) +P2(day,hour)+P3(day,hour) = LD(Day,hour) for all days and hours in the year.

Any suggestions on how to determine Y1,Y2,and Y3 subject to these constraints would be appreciated. To me this sounds like an optimization problem, however I am not that familiar with the optimization toolbox. I have been trying to solve using fgoalobtain but never reaches a solution, it runs for about an hour and I end up stopping it as I figure after that ammount of time if it doesnt reach a solution it is not going to or I have entered somthing incorrectly. Below are the code used so far, there is quite a bit.

%%%%%%%%%%%%%%%%%%%%
Scalling functions:

function signalOut = signalScale(baseSignal,targetMin,targetMax)


target = [targetMin targetMax];
baseChar = [min(baseSignal(:)) max(baseSignal(:))];

%determination of process
test = fliplr(target) - baseChar;

if sum(test<0) == 2
    signalOut = scaleValleys(baseSignal,target);
    signalOut = scalePeaks(signalOut,target);
else
    signalOut = scalePeaks(baseSignal,target);
    signalOut = scaleValleys(signalOut,target);
end
    
   function signalOut = scaleValleys(baseSignal,target)
    
   baseChar = [min(baseSignal(:)) max(baseSignal(:))];
   alphaMax = diff(baseChar);
   signalOut = zeros(size(baseSignal));
   x = @(alpha) alphaMax/(alphaMax-alpha);
   %scale valleys
   if baseChar(1) > target(1)
        peakDiff=(baseChar(1)-target(1))/target(1);
        
        for day=1:size(baseSignal,1)
            for hour=1:24
               alpha=max(baseChar(1),baseSignal(day,hour))-...
                   min(baseChar(1),baseSignal(day,hour));
                if alpha == alphaMax
                    alpha = alpha - 1e-43;
                end
                    signalOut(day,hour)=baseSignal(day,hour)/...
                            ((peakDiff)/(x(alpha))+1);
            end
        end
   elseif baseChae(1) < target(1)
        peakDiff=(target(1)-baseChar(1))/baseChar(1);
        for day=1:size(baseSignal,1)
            for hour=1:24
                alpha=max(baseChar(1),baseSignal(day,hour))-...
                    min(baseChar(1),baseSignal(day,hour));
                if alpha == alphaMax
                    alpha = alpha - 1e-43;
                end
                    signalOut(day,hour)=baseSignal(day,hour)*...
                            ((peakDiff)/(x(alpha))+1);
            end
        end
   else
       signalOut = baseSignal;
   end

function signalOut = scalePeaks(baseSignal,target)
    
   baseChar = [min(baseSignal(:)) max(baseSignal(:))];
   alphaMax = diff(baseChar);
   signalOut = zeros(size(baseSignal));
   x = @(alpha) alphaMax/(alphaMax-alpha);

   %scale peaks
   if baseChar(2) > target(2)
        peakDiff=(baseChar(2)-target(2))/target(2);
        
        for day=1:size(baseSignal,1)
            for hour=1:24
                alpha=max(baseChar(2),baseSignal(day,hour))-...
                    min(baseChar(2),baseSignal(day,hour));
                if alpha == alphaMax
                    alpha = alpha - 1e-43;
                end
                    signalOut(day,hour)=baseSignal(day,hour)/...
                            ((peakDiff)/(x(alpha))+1);
            end
        end
   elseif baseChae(2) < target(2)
        peakDiff=(target(2)-baseChar(2))/baseChar(2);
        for day=1:size(baseSignal,1)
            for hour=1:24
                alpha=max(baseChar(2),baseSignal(day,hour))-...
                    min(baseChar(2),baseSignal(day,hour));
                if alpha == alphaMax
                    alpha = alpha - 1e-43;
                end
                    signalOut(day,hour)=baseSignal(day,hour)*...
                            ((peakDiff)/(x(alpha))+1);
            end
        end
   else
       signalOut = baseSignal;
   end

%%%%%%%%%%%%%%%%%%%%%

The Targets and Base Signal are imported from excel and seperated into months but i figured I did not need to share that portion, if I do let me know andI can post it.

The sclaing operations are done for each month and for each of the 3 regions.

%%%%%%%%%%%%%%%%%%%%%%%
Then my attempt at using fgoalobtain for january

LD_month = zeros(31,31);
LD_month(1:31,1:24) = LD(1:31,:);
y = zeros(31,31,3);
for i = 1:3
    newMonthlyStats(:,:,i) = xlsread('monthlyLoadStats1.xls',sheet{1,i},'N23:P34');
    y(1:31,1:24,i) = X(1:31,:,i);
end
Z = zeros(31,31);
Z(1:31,1:24) = sum(y,3);
dE = LD_month-Z;

x0 = zeros([31 31 3]);
x0(1:31,1:24,:) = 1;
weight = ones(size(LD));
goal = LD;

targetEnergyRegion1=newMonthlyStats(1,1,1);
targetEnergyRegion2=newMonthlyStats(1,1,2);
targetEnergyRegion3=newMonthlyStats(1,1,3);

x = fgoalattain(@(x) fun(x,y(:,:,1),y(:,:,2),y(:,:,3),LD,dE),x0,goal,weight,[],[],[],[],[],[],@(x) confun(x,y(:,:,1),y(:,:,2),y(:,:,3),targetEnergyRegion1,targetEnergyRegion2,targetEnergyRegion3,dE));



function f=fun(x,p1,p2,p3,P,E)
f = P - ((p1+E*x(:,:,1))+(p2+E*x(:,:,2))+(p3+E*x(:,:,3)));


function [c ceq] = confun(x,p1,p2,p3,g1,g2,g3,dE)
c=[];
ceq(1) = g1-sum(sum(p1 +dE*x(:,:,1)));
ceq(2) = g2-sum(sum(p2+dE*x(:,:,2)));
ceq(3) = g3-sum(sum(p3+dE*x(:,:,3)));


Again, any help or suggestions are appreciate, if I have done a poor job explaining my problem or you feel as though I have left any important information out, please let me know.

Nick

Subject: Optimization Problem, Linear Equations with multiple constraints

From: EE Student

Date: 13 Jun, 2010 21:15:05

Message: 2 of 7

"EE Student " <np7@cec.wustl.edu> wrote in message <hv3h60$d1d$1@fred.mathworks.com>...
> Hey guys, I have a problem I have been working on for a bit and seem to be stuck with. Hopefully I can describe the problem well enough so that everyone understands what I am trying to do. Just so everyone knows, this is not a homework or school related problem. What I have is a matrix, lets call it LD, which has size = [365 24]. Yep, you guessed it, its 365 days worth of hourly data. I also have 3 sets of monthly target data. The target data described the hourly maximum, hourly minimum, and total energy for each month for 3 regions. My goal is to take my known matrix LD, and scale it such that I create 3 new matrices, call the P1, P2, and P3 such that the targets for each month, for each region are met. My initial approach is to scale LD on a monthly basis for each of the target regions to create 3 new matrices that meet the monthly max and min target, then to ajust these new

> matrices to match the monthly energy targets.
>
> This is not my code but an attempt to explain my goals using equations, and also note that siince I have monthly target numbers each of these in effect will represent a months worth of hourly data and the process will be repeated 12 times.
>
> LD = P1 + P2 + P3;
> P1 = LD * S1 + E*Y1
> P2 = LD * S2 + E*Y2
> P3 = LD * S3 + E*Y3
>
> Where
>
> S1,S2,S3 are the scale factors to meet the monthly max and min targets.
>
> X1 = LD*S1
> X2 = LD*S2
> X3 = LD*S3
>
> X1,X2,X3 are known ouputs of the scaling portion of the algorithm which has been accomplished. Therefore in the following equations X1,X2,X3 and LD are all known matrices with size = [number_of _days_in_month hour] and the minimum and maximum targets are exactly met by the respective X matrices for each region so these two hours in each of the X matices cannot be adjusted further.
>
> LD = X1 + X2 + X3 + E
> P1 = X1 + E*Y1
> P2 = X2 + E*Y2
> P3 = X3 + E*Y3
>
> E = LD - sum(X1+X2+X3)
>
> sum(P1) = monthly energy target for region 1
> sum(P2) = monthly energy target for region 2
> sum(P3) = monthly energy target for region 3
>
> P1(day,hour) +P2(day,hour)+P3(day,hour) = LD(Day,hour) for all days and hours in the year.
>
> Any suggestions on how to determine Y1,Y2,and Y3 subject to these constraints would be appreciated. To me this sounds like an optimization problem, however I am not that familiar with the optimization toolbox. I have been trying to solve using fgoalobtain but never reaches a solution, it runs for about an hour and I end up stopping it as I figure after that ammount of time if it doesnt reach a solution it is not going to or I have entered somthing incorrectly. Below are the code used so far, there is quite a bit.
>
> %%%%%%%%%%%%%%%%%%%%
> Scalling functions:
>
> function signalOut = signalScale(baseSignal,targetMin,targetMax)
>
>
> target = [targetMin targetMax];
> baseChar = [min(baseSignal(:)) max(baseSignal(:))];
>
> %determination of process
> test = fliplr(target) - baseChar;
>
> if sum(test<0) == 2
> signalOut = scaleValleys(baseSignal,target);
> signalOut = scalePeaks(signalOut,target);
> else
> signalOut = scalePeaks(baseSignal,target);
> signalOut = scaleValleys(signalOut,target);
> end
>
> function signalOut = scaleValleys(baseSignal,target)
>
> baseChar = [min(baseSignal(:)) max(baseSignal(:))];
> alphaMax = diff(baseChar);
> signalOut = zeros(size(baseSignal));
> x = @(alpha) alphaMax/(alphaMax-alpha);
> %scale valleys
> if baseChar(1) > target(1)
> peakDiff=(baseChar(1)-target(1))/target(1);
>
> for day=1:size(baseSignal,1)
> for hour=1:24
> alpha=max(baseChar(1),baseSignal(day,hour))-...
> min(baseChar(1),baseSignal(day,hour));
> if alpha == alphaMax
> alpha = alpha - 1e-43;
> end
> signalOut(day,hour)=baseSignal(day,hour)/...
> ((peakDiff)/(x(alpha))+1);
> end
> end
> elseif baseChae(1) < target(1)
> peakDiff=(target(1)-baseChar(1))/baseChar(1);
> for day=1:size(baseSignal,1)
> for hour=1:24
> alpha=max(baseChar(1),baseSignal(day,hour))-...
> min(baseChar(1),baseSignal(day,hour));
> if alpha == alphaMax
> alpha = alpha - 1e-43;
> end
> signalOut(day,hour)=baseSignal(day,hour)*...
> ((peakDiff)/(x(alpha))+1);
> end
> end
> else
> signalOut = baseSignal;
> end
>
> function signalOut = scalePeaks(baseSignal,target)
>
> baseChar = [min(baseSignal(:)) max(baseSignal(:))];
> alphaMax = diff(baseChar);
> signalOut = zeros(size(baseSignal));
> x = @(alpha) alphaMax/(alphaMax-alpha);
>
> %scale peaks
> if baseChar(2) > target(2)
> peakDiff=(baseChar(2)-target(2))/target(2);
>
> for day=1:size(baseSignal,1)
> for hour=1:24
> alpha=max(baseChar(2),baseSignal(day,hour))-...
> min(baseChar(2),baseSignal(day,hour));
> if alpha == alphaMax
> alpha = alpha - 1e-43;
> end
> signalOut(day,hour)=baseSignal(day,hour)/...
> ((peakDiff)/(x(alpha))+1);
> end
> end
> elseif baseChae(2) < target(2)
> peakDiff=(target(2)-baseChar(2))/baseChar(2);
> for day=1:size(baseSignal,1)
> for hour=1:24
> alpha=max(baseChar(2),baseSignal(day,hour))-...
> min(baseChar(2),baseSignal(day,hour));
> if alpha == alphaMax
> alpha = alpha - 1e-43;
> end
> signalOut(day,hour)=baseSignal(day,hour)*...
> ((peakDiff)/(x(alpha))+1);
> end
> end
> else
> signalOut = baseSignal;
> end
>
> %%%%%%%%%%%%%%%%%%%%%
>
> The Targets and Base Signal are imported from excel and seperated into months but i figured I did not need to share that portion, if I do let me know andI can post it.
>
> The sclaing operations are done for each month and for each of the 3 regions.
>
> %%%%%%%%%%%%%%%%%%%%%%%
> Then my attempt at using fgoalobtain for january
>
> LD_month = zeros(31,31);
> LD_month(1:31,1:24) = LD(1:31,:);
> y = zeros(31,31,3);
> for i = 1:3
> newMonthlyStats(:,:,i) = xlsread('monthlyLoadStats1.xls',sheet{1,i},'N23:P34');
> y(1:31,1:24,i) = X(1:31,:,i);
> end
> Z = zeros(31,31);
> Z(1:31,1:24) = sum(y,3);
> dE = LD_month-Z;
>
> x0 = zeros([31 31 3]);
> x0(1:31,1:24,:) = 1;
> weight = ones(size(LD));
> goal = LD;
>
> targetEnergyRegion1=newMonthlyStats(1,1,1);
> targetEnergyRegion2=newMonthlyStats(1,1,2);
> targetEnergyRegion3=newMonthlyStats(1,1,3);
>
> x = fgoalattain(@(x) fun(x,y(:,:,1),y(:,:,2),y(:,:,3),LD,dE),x0,goal,weight,[],[],[],[],[],[],@(x) confun(x,y(:,:,1),y(:,:,2),y(:,:,3),targetEnergyRegion1,targetEnergyRegion2,targetEnergyRegion3,dE));
>
>
>
> function f=fun(x,p1,p2,p3,P,E)
> f = P - ((p1+E*x(:,:,1))+(p2+E*x(:,:,2))+(p3+E*x(:,:,3)));
>
>
> function [c ceq] = confun(x,p1,p2,p3,g1,g2,g3,dE)
> c=[];
> ceq(1) = g1-sum(sum(p1 +dE*x(:,:,1)));
> ceq(2) = g2-sum(sum(p2+dE*x(:,:,2)));
> ceq(3) = g3-sum(sum(p3+dE*x(:,:,3)));
>
>
> Again, any help or suggestions are appreciate, if I have done a poor job explaining my problem or you feel as though I have left any important information out, please let me know.
>
> Nick


Oh and my mistake, I accidently called the function fgoalobtain instead it should have been fgoalattain and in the snips of code

this:
weight = ones(size(LD));
 goal = LD;

should have been:
weight = ones(size(LD_month));
 goal = LD_month;

I was chaning the variable from my actual code to match the equation I used to descibe the problem above and missed these changes. Hopefully I didnt miss any other but I would hope you can see what I was trying to do


Thanks

Subject: Optimization Problem, Linear Equations with multiple constraints

From: Bruno Luong

Date: 14 Jun, 2010 06:23:03

Message: 3 of 7

"EE Student " <np7@cec.wustl.edu> wrote in message <hv3h60$d1d$1@fred.mathworks.com>...
>
>
> LD = X1 + X2 + X3 + E
> P1 = X1 + E*Y1
> P2 = X2 + E*Y2
> P3 = X3 + E*Y3
>
> E = LD - sum(X1+X2+X3)
>
> sum(P1) = monthly energy target for region 1
> sum(P2) = monthly energy target for region 2
> sum(P3) = monthly energy target for region 3
>
> P1(day,hour) +P2(day,hour)+P3(day,hour) = LD(Day,hour) for all days and hours in the year.
>

It looks like the problem can be solved with simple linear algebra. But your description is still unclear to me because it mixing between mathematics equations and verbose.

If you can just write in term of matrix equations: given the size, equation+constraints, what is known what is unknown (that can't be that hard?), it would help.

For example, instead of saying "sum(P1) = monthly energy target for region 1", you can just say "sum(P1,1) = t1, t1 is known".

My bet is after you are able to write down the system in a clear manner, the solution will pop up straight way.

Bruno

Subject: Optimization Problem, Linear Equations with multiple constraints

From: EE Student

Date: 14 Jun, 2010 15:13:04

Message: 4 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hv4hs7$8i3$1@fred.mathworks.com>...
> "EE Student " <np7@cec.wustl.edu> wrote in message <hv3h60$d1d$1@fred.mathworks.com>...
> >
> >
> > LD = X1 + X2 + X3 + E
> > P1 = X1 + E*Y1
> > P2 = X2 + E*Y2
> > P3 = X3 + E*Y3
> >
> > E = LD - sum(X1+X2+X3)
> >
> > sum(P1) = monthly energy target for region 1
> > sum(P2) = monthly energy target for region 2
> > sum(P3) = monthly energy target for region 3
> >
> > P1(day,hour) +P2(day,hour)+P3(day,hour) = LD(Day,hour) for all days and hours in the year.
> >
>
> It looks like the problem can be solved with simple linear algebra. But your description is still unclear to me because it mixing between mathematics equations and verbose.
>
> If you can just write in term of matrix equations: given the size, equation+constraints, what is known what is unknown (that can't be that hard?), it would help.
>
> For example, instead of saying "sum(P1) = monthly energy target for region 1", you can just say "sum(P1,1) = t1, t1 is known".
>
> My bet is after you are able to write down the system in a clear manner, the solution will pop up straight way.
>
> Bruno


Bruno,

You are correct, I think this can be solved using linear algebra and my discription was a bit hard to follow after I reread it. I will try and right in in terms of MATLAB. Furthermore, even though I will be looking at this in terms of a years worth of data, lets consider the case of just one month since I have monthly target values.


Let matrix LD be my known hourly data such that

[days_in_month 24] = size(LD);

Let matrix Targets be my known monthly target values for each region such that

[1 3 3] = size(Targets);



Let X be the desired result

X = zeros([days_in_month 24 3]);

Constraint Equations:
sum(X(:)) == sum(Targets(1,1,:),3) == sum(LD(:))

These next lines are still constraint equations and should be true for all i and j:
sum(X(i,j,:),3) == LD(i,j);

X(i,j,1) <= Target(1,2,1);
X(i,j,2) <= Target(1,2,2);
X(i,j,3) <= Target(1,2,3);

X(i,j,1) >= Target(1,3,1);
X(i,j,2) >= Target(1,3,2);
X(i,j,3) >= Target(1,3,3);



Let Matix M be a matrix of multipliers to satisfy:

X(:,:,1) = LD*M(:,:,1);
X(:,:,2) = LD*M(:,:,2);
X(:,:,3) = LD*M(:,:,3);

Therfore

LD = LD*M(:,:,1)+LD*M(:,:,2)+LD*M(:,:,3);

It goes without saying that I would want to repeat this process for all 12 months. Of course in terms of the Matrix M, the multilpcation would either have to actualy be

X(:,:,1) = LD.*M(:,:,1)

or I would need to extend the matrices with zeros so they are all square to use matrix multiplication.

As an intermediate step, using the "scaling functions" posted before I was trying to satisfy the minimum and maximum constraints and then take take of the total energy diffrence after scaling the peaks and minimums. Maybe that is the wrong way to think about it. At any rate I hope this is more clear and with any luck maybe Ill have figured it out myself soon enough.

Thanks,

Nick

Subject: Optimization Problem, Linear Equations with multiple constraints

From: Bruno Luong

Date: 14 Jun, 2010 17:33:07

Message: 5 of 7

"EE Student " <np7@cec.wustl.edu> wrote in message <hv5gu0$k2e$1@fred.mathworks.com>...
>
>
> Let matrix LD be my known hourly data such that
>
> [days_in_month 24] = size(LD);
>
> Let matrix Targets be my known monthly target values for each region such that
>
> [1 3 3] = size(Targets);
>
>
>
> Let X be the desired result
>
> X = zeros([days_in_month 24 3]);
>
> Constraint Equations:
> sum(X(:)) == sum(Targets(1,1,:),3) == sum(LD(:))
>
> These next lines are still constraint equations and should be true for all i and j:
> sum(X(i,j,:),3) == LD(i,j);
>
> X(i,j,1) <= Target(1,2,1);
> X(i,j,2) <= Target(1,2,2);
> X(i,j,3) <= Target(1,2,3);
>
> X(i,j,1) >= Target(1,3,1);
> X(i,j,2) >= Target(1,3,2);
> X(i,j,3) >= Target(1,3,3);
>
>

Until here is fine.

>
> Let Matix M be a matrix of multipliers to satisfy:
>
> X(:,:,1) = LD*M(:,:,1);
> X(:,:,2) = LD*M(:,:,2);
> X(:,:,3) = LD*M(:,:,3);
>
> Therfore
>
> LD = LD*M(:,:,1)+LD*M(:,:,2)+LD*M(:,:,3);
>

In what sense should *we* care about M? M can be always computed from LD and X.

M(:,:,k) = inv(LD)* X(:,:,1) for k=1,2,3.

Isn't the problem self-sufficient described with X, LD and Target alone?

Assuming the answer to this question is "yes", all the constraints are linear:

sum(X(:)) == sum(Targets(1,1,:),3) == sum(LD(:))
sum(X(i,j,:),3) == LD(i,j);
X(i,j,1) <= Target(1,2,1);
X(i,j,2) <= Target(1,2,2);
X(i,j,3) <= Target(1,2,3);
X(i,j,1) >= Target(1,3,1);
X(i,j,2) >= Target(1,3,2);
X(i,j,3) >= Target(1,3,3);

This problem is equivalent to find a feasible of the linear inequalities; or equivalently find a point belong to the convex set. You can use LINPROG with niter =1 and dummy cost function, it should return "one" solution, if such solution exists.

Bruno

Subject: Optimization Problem, Linear Equations with multiple constraints

From: EE Student

Date: 14 Jun, 2010 23:35:21

Message: 6 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hv5p4j$5n0$1@fred.mathworks.com>...
> "EE Student " <np7@cec.wustl.edu> wrote in message <hv5gu0$k2e$1@fred.mathworks.com>...
> >
> >
> > Let matrix LD be my known hourly data such that
> >
> > [days_in_month 24] = size(LD);
> >
> > Let matrix Targets be my known monthly target values for each region such that
> >
> > [1 3 3] = size(Targets);
> >
> >
> >
> > Let X be the desired result
> >
> > X = zeros([days_in_month 24 3]);
> >
> > Constraint Equations:
> > sum(X(:)) == sum(Targets(1,1,:),3) == sum(LD(:))
> >
> > These next lines are still constraint equations and should be true for all i and j:
> > sum(X(i,j,:),3) == LD(i,j);
> >
> > X(i,j,1) <= Target(1,2,1);
> > X(i,j,2) <= Target(1,2,2);
> > X(i,j,3) <= Target(1,2,3);
> >
> > X(i,j,1) >= Target(1,3,1);
> > X(i,j,2) >= Target(1,3,2);
> > X(i,j,3) >= Target(1,3,3);
> >
> >
>
> Until here is fine.
>
> >
> > Let Matix M be a matrix of multipliers to satisfy:
> >
> > X(:,:,1) = LD*M(:,:,1);
> > X(:,:,2) = LD*M(:,:,2);
> > X(:,:,3) = LD*M(:,:,3);
> >
> > Therfore
> >
> > LD = LD*M(:,:,1)+LD*M(:,:,2)+LD*M(:,:,3);
> >
>
> In what sense should *we* care about M? M can be always computed from LD and X.
>
> M(:,:,k) = inv(LD)* X(:,:,1) for k=1,2,3.
>
> Isn't the problem self-sufficient described with X, LD and Target alone?
>
> Assuming the answer to this question is "yes", all the constraints are linear:
>
> sum(X(:)) == sum(Targets(1,1,:),3) == sum(LD(:))
> sum(X(i,j,:),3) == LD(i,j);
> X(i,j,1) <= Target(1,2,1);
> X(i,j,2) <= Target(1,2,2);
> X(i,j,3) <= Target(1,2,3);
> X(i,j,1) >= Target(1,3,1);
> X(i,j,2) >= Target(1,3,2);
> X(i,j,3) >= Target(1,3,3);
>
> This problem is equivalent to find a feasible of the linear inequalities; or equivalently find a point belong to the convex set. You can use LINPROG with niter =1 and dummy cost function, it should return "one" solution, if such solution exists.
>
> Bruno

Bruno,

Thanks for the tips, I did get a somewhat reasonable solution. I envisioned this being an LP problem but I dont have much experience with optimization as of yet and definately had trouble with the syntax. I noticed you have posted some files in the exchange dealing with optimization, is this your area of expertise? A few more questions for you, hopefully you do not mind. The way I ended up setting up the solver, I was using the number of hours in the working month * 3 for my variables I was solving for so between 2016 and 2232 variable which made it a large scale problem, however the large scale algorithm doesnt accept initial conditions. I was thinking that inputting the output of my max/min scaling code as initial considitions would aid the solution but if I turn off the large scale algorithm the solution time increases exponentially. Might you know of any ways around this or
am I barking up the wrong tree?

Thanks,

Nick

Subject: Optimization Problem, Linear Equations with multiple constraints

From: Bruno Luong

Date: 15 Jun, 2010 05:05:04

Message: 7 of 7

"EE Student " <np7@cec.wustl.edu> wrote in message <hv6ebp$7de$1@fred.mathworks.com>...
>
> Thanks for the tips, I did get a somewhat reasonable solution. I envisioned this being an LP problem but I dont have much experience with optimization as of yet and definately had trouble with the syntax. I noticed you have posted some files in the exchange dealing with optimization, is this your area of expertise?

I'm not sure if I have one area of expertise. I'm only optimization end users.

> A few more questions for you, hopefully you do not mind. The way I ended up setting up the solver, I was using the number of hours in the working month * 3 for my variables I was solving for so between 2016 and 2232 variable which made it a large scale problem, however the large scale algorithm doesnt accept initial conditions. I was thinking that inputting the output of my max/min scaling code as initial considitions would aid the solution but if I turn off the large scale algorithm the solution time increases exponentially. Might you know of any ways around this or
> am I barking up the wrong tree?

I can't help you here, I do not own optimization toolbox. The LP code I currently use is PCx, which can solve 2000 variable problem in no time (In one of the problem with 50k variables it takes 0.5 second)

Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us