COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Implicit function within linprog for loop

• Follow

```Hi I have the following code

Diesel_cost_per_kWh = 0.4;
a = 0.0082;
b = 0.023;
c = 0.253

for j = 1:24

diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c

Diesel_cost(j) =  diesel_power_out(j,i)*Diesel_cost_per_kWh

A(j,:) = [-PV_supply(j,:) -WT_supply(j,:) -diesel_power_out(j,:)];

b(j) = -Demand(j);

f(:,j) = [CRF_PV*CC_PV/8760;CRF_WT*CC_WT/8760;CRF_Diesel_generator*CC_Diesel+Diesel_cost(j)/8760];

[x(j,:),fval(:,j),exitflag(:,j)] = linprog(f(:,j),A(j,:),b(j))

end

Where PV_supply and WT_supply are 24x1 vectors with known values of each element.
What I am trying to do is find the "optimum" x1, x2 and x3 value per hour for this data set and my objective function is a minimum cost function.

However, as you can see the "diesel_power_out" is some sort of implicit function which I am trying to solve simultaneously with linprog.
Therefore I am trying to find the optimum "diesel_power_out" value for each of the 24 hours that meets the objective and criteria  from the expression shown above as

diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c

I am not really sure where to start, and was hoping for advice on this and if such a task is even possible.
Do I need some sort of iteration that is taking place within the linprog for loop?

```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <da577c84-19fa-48dc-9fc7-2c8c3ec845c0@googlegroups.com>...
> Hi I have the following code
>
>
> Diesel_cost_per_kWh = 0.4;
> a = 0.0082;
> b = 0.023;
> c = 0.253
>
> for j = 1:24
>
>
>     diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c
>
>
>     Diesel_cost(j) =  diesel_power_out(j,i)*Diesel_cost_per_kWh
>
>
>     A(j,:) = [-PV_supply(j,:) -WT_supply(j,:) -diesel_power_out(j,:)];
>
>     b(j) = -Demand(j);
>
>
>     f(:,j) = [CRF_PV*CC_PV/8760;CRF_WT*CC_WT/8760;CRF_Diesel_generator*CC_Diesel+Diesel_cost(j)/8760];
>
>
>     [x(j,:),fval(:,j),exitflag(:,j)] = linprog(f(:,j),A(j,:),b(j))
>
> end
>
> Where PV_supply and WT_supply are 24x1 vectors with known values of each element.
> What I am trying to do is find the "optimum" x1, x2 and x3 value per hour for this data set and my objective function is a minimum cost function.
>
> However, as you can see the "diesel_power_out" is some sort of implicit function which I am trying to solve simultaneously with linprog.
> Therefore I am trying to find the optimum "diesel_power_out" value for each of the 24 hours that meets the objective and criteria  from the expression shown above as
>
>     diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c
>

I for one, grasp little of the problem, as you've explained it.  As far as I can tell, your diesel_power_out data is supposed to be the solution of the equation

z=a*z^2+b*z+c

If so, the solution to the above is equivalent to finding the roots of the quadratic

a*z^2+(b-1)*z+c = 0

and should be pretty trivial using the ROOTS command.
```
 0
Reply mattjacREMOVE (3190) 7/6/2012 10:07:07 PM

```On Friday, 6 July 2012 19:21:35 UTC+1, Andrew Alkiviades  wrote:
> Hi I have the following code
>
>
> Diesel_cost_per_kWh = 0.4;
> a = 0.0082;
> b = 0.023;
> c = 0.253
>
> for j = 1:24
>
>
>     diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c
>
>
>     Diesel_cost(j) =  diesel_power_out(j,i)*Diesel_cost_per_kWh
>
>
>     A(j,:) = [-PV_supply(j,:) -WT_supply(j,:) -diesel_power_out(j,:)];
>
>     b(j) = -Demand(j);
>
>
>     f(:,j) = [CRF_PV*CC_PV/8760;CRF_WT*CC_WT/8760;CRF_Diesel_generator*CC_Diesel+Diesel_cost(j)/8760];
>
>
>     [x(j,:),fval(:,j),exitflag(:,j)] = linprog(f(:,j),A(j,:),b(j))
>
> end
>
> Where PV_supply and WT_supply are 24x1 vectors with known values of each element.
> What I am trying to do is find the "optimum" x1, x2 and x3 value per hour for this data set and my objective function is a minimum cost function.
>
> However, as you can see the "diesel_power_out" is some sort of implicit function which I am trying to solve simultaneously with linprog.
> Therefore I am trying to find the optimum "diesel_power_out" value for each of the 24 hours that meets the objective and criteria  from the expression shown above as
>
>     diesel_power_out(j,:) = a*diesel_power_out(j)^2 + b*diesel_power_out(j) + c
>
> I am not really sure where to start, and was hoping for advice on this and if such a task is even possible.
> Do I need some sort of iteration that is taking place within the linprog for loop?
>

Hi Matt
Since the diesel_power_out is also a constraint in matrix "A" are you saying that I can find the point on the polynomial curve that satisfies the inequality constraint "A" and also minimizing the obj func with:
diesel_coef = (a b c );
A(j,:) = [-PV_supply(j,:) -WT_supply(j,:) -roots(diesel_coef(j,:) ];

The important thing is that the solution can be anywhere on that curve as long as it minizimes the function and ofcourse meets constraints so with the roots function arent I just solving the polynomial only?
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <ac0d4ab4-edc8-4dd0-932a-e606dc339ec2@googlegroups.com>...
>
> Since the diesel_power_out is also a constraint in matrix "A" are you saying that I can find the point on the polynomial curve that satisfies the inequality constraint "A" and also minimizing the obj func with:
=============

You haven't mentioned any constraints  on diesel_power_out. Only on x1,x2,x3.

Now, you seem to say that diesel_power_out both determines the constraint matrix "A" and is also subject to those constraints????????????????
```
 0
Reply mattjacREMOVE (3190) 7/6/2012 11:17:25 PM

```yes as I have shown in my first post the x3 coefficient of the objective fu=
nction "f" depends on the "diesel_cost(j)" which is a function of "diesel_p=
ower_output". This "diesel_power_output" is also a coefficient of the x3 in=
equality constraint "A". So maybe the first question should be, is somethin=
g like this possible?=20
i.e is it possible to find what the hourly diesel power output should be th=
at will minimize the "diesel_cost" and also meet the inequality constraint?
hope that is clearer!
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <27613538-c9a4-492a-bc96-179194b5e5ac@googlegroups.com>...
> yes as I have shown in my first post the x3 coefficient of the objective function "f" depends on the "diesel_cost(j)" which is a function of "diesel_power_output". This "diesel_power_output" is also a coefficient of the x3 inequality constraint "A". So maybe the first question should be, is something like this possible?
> i.e is it possible to find what the hourly diesel power output should be that will minimize the "diesel_cost" and also meet the inequality constraint?
====================

Well, according to your original post, diesel_power_output has to be the root of a quadratic, so there are at most 2 values it can possibly have. You can check which of these values minimizes the diesel_cost. Once you've solved for diesel_power_output, you can plug it into the expressions for A and f and use LINPROG to see if the resulting linear program has a solution.
```
 0
Reply mattjacREMOVE (3190) 7/7/2012 4:26:08 PM

```On Saturday, 7 July 2012 17:26:08 UTC+1, Matt J   wrote:
> > yes as I have shown in my first post the x3 coefficient of the objectiv=
e function "f" depends on the "diesel_cost(j)" which is a function of "dies=
el_power_output". This "diesel_power_output" is also a coefficient of the x=
3 inequality constraint "A". So maybe the first question should be, is some=
thing like this possible?=20
> > i.e is it possible to find what the hourly diesel power output should b=
e that will minimize the "diesel_cost" and also meet the inequality constra=
int?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Well, according to your original post, diesel_power_output has to be the =
root of a quadratic, so there are at most 2 values it can possibly have. Yo=
u can check which of these values minimizes the diesel_cost. Once you've so=
lved for diesel_power_output, you can plug it into the expressions for A an=
d f and use LINPROG to see if the resulting linear program has a solution.

Yes but the thing is that that diesel_power_output is also a part of the co=
nstraint "A" so  even though the diesel_cost may be a minimum at the roots,=
the overall function may not be right?
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <7c12f07d-5e0f-4dce-ae16-4f53aac4b2b7@googlegroups.com>...
>
> > Well, according to your original post, diesel_power_output has to be the root of a quadratic, so there are at most 2 values it can possibly have. You can check which of these values minimizes the diesel_cost. Once you've solved for diesel_power_output, you can plug it into the expressions for A and f and use LINPROG to see if the resulting linear program has a solution.
>
> Yes but the thing is that that diesel_power_output is also a part of the constraint "A" so  even though the diesel_cost may be a minimum at the roots, the overall function may not be right?
=============

So, first of all, I don't think diesel_cost will be minimized at both roots. In your initial post, diesel_cost was proportional to diesel_power_output, so it will probably be minimized at the smallest root, the one which gives the smallest value of diesel_power_output.

But yes, what you seem to be saying is that you have 2 objective functions (f and diesel_cost), each one partly a function of diesel_power_output. There is no reason to expect that both objective functions can be minimized simultaneously for a single choice of diesel_power_output.
```
 0
Reply mattjacREMOVE (3190) 7/7/2012 5:17:09 PM

```On Saturday, 7 July 2012 18:17:09 UTC+1, Matt J   wrote:
> >
> > > Well, according to your original post, diesel_power_output has to be =
the root of a quadratic, so there are at most 2 values it can possibly have=
.. You can check which of these values minimizes the diesel_cost. Once you'v=
e solved for diesel_power_output, you can plug it into the expressions for =
A and f and use LINPROG to see if the resulting linear program has a soluti=
on.
> >=20
> > Yes but the thing is that that diesel_power_output is also a part of th=
e constraint "A" so  even though the diesel_cost may be a minimum at the ro=
ots, the overall function may not be right?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> So, first of all, I don't think diesel_cost will be minimized at both roo=
ts. In your initial post, diesel_cost was proportional to diesel_power_outp=
ut, so it will probably be minimized at the smallest root, the one which gi=
ves the smallest value of diesel_power_output.
>=20
> But yes, what you seem to be saying is that you have 2 objective function=
s (f and diesel_cost), each one partly a function of diesel_power_output. T=
here is no reason to expect that both objective functions can be minimized =
simultaneously for a single choice of diesel_power_output.

Thanks Matt

See, physically speaking I am looking for the minimum capital cost of a die=
sel generator, PV module and wind turbine under the constraints (supply >=
=3D demand ) in matrix A.
I can treat the diesel consumption polynomial individually and find the die=
sel_power_output this satisfies. However, in the bigger picture, this diese=
l consumption should be changing per hour in the "for loop" so as to 1) mee=
t constraints 2) minimise the initial objective function "f".

I guess one of the main reasons I posted this question is to ask whether or=
not such a task is achievable in which my understanding from you is that t=
his cannot be done right?
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <dc12fddc-a429-413f-8ef3-218094d2a030@googlegroups.com>...
> On Saturday, 7 July 2012 18:17:09 UTC+1, Matt J   wrote:
> > >
> > > > Well, according to your original post, diesel_power_output has to be the root of a quadratic, so there are at most 2 values it can possibly have. You can check which of these values minimizes the diesel_cost. Once you've solved for diesel_power_output, you can plug it into the expressions for A and f and use LINPROG to see if the resulting linear program has a solution.
> > >
> > > Yes but the thing is that that diesel_power_output is also a part of the constraint "A" so  even though the diesel_cost may be a minimum at the roots, the overall function may not be right?
> > =============
> >
> > So, first of all, I don't think diesel_cost will be minimized at both roots. In your initial post, diesel_cost was proportional to diesel_power_output, so it will probably be minimized at the smallest root, the one which gives the smallest value of diesel_power_output.
> >
> > But yes, what you seem to be saying is that you have 2 objective functions (f and diesel_cost), each one partly a function of diesel_power_output. There is no reason to expect that both objective functions can be minimized simultaneously for a single choice of diesel_power_output.
>
> Thanks Matt
>
> See, physically speaking I am looking for the minimum capital cost of a diesel generator, PV module and wind turbine under the constraints (supply >= demand ) in matrix A.
> I can treat the diesel consumption polynomial individually and find the diesel_power_output this satisfies. However, in the bigger picture, this diesel consumption should be changing per hour in the "for loop" so as to 1) meet constraints 2) minimise the initial objective function "f".
>
> I guess one of the main reasons I posted this question is to ask whether or not such a task is achievable in which my understanding from you is that this cannot be done right?

It's achievable as long as you're only trying to minimize f*x, however, you keep saying that you're also trying to minimize not only f*x but a 2nd objective function as well called "diesel_cost". You can't minimize 2 things at the same time.

If you're now saying you only want to minimize f*x, then yes it's possible as long as I'm understanding the problem correctly. Below I have what I believe to be the mathematical formulation of your problem. To make discussion easier, I've relabeled diesel_power_output as z. So now you have 4 unknowns x2,x2,x3,z and you are trying to solve:

min f(z)*x

subject to constraints

A(z)*x<=demand
a*z^2+(b-1)*z+c=0

The dependence of f(z) and A(z) are not important. It is only important to know that for a fixed z, you get a linear program in x. There are at most two possible values that z can have satisfying the quadratic equality constraint above. So, for each of those choices z1 and z2, you can solve the corresponding linear program and take the best of the optimal objective values f(z1)*x or f(z2)*x
```
 0
Reply mattjacREMOVE (3190) 7/7/2012 5:56:07 PM

```Matt thank you for you help and sorry for the confusion but I have come acr=
oss a new equation that may help

remember that I am trying to optimise the cost function "f". The problem I =
have is that I know the values in the vector "PV_supply" and "WT_supply" of=
which I am looking for the number of units as (x1 an x2) but I don't know =
the values in "Diesel_supply" which i am of course trying to find out (as w=
ell as the number of units)=20

I have come across the equation=20

Diesel_cost =3D diesel_cost_litres*( b*diesel_generator_capacity + a*diesel=
_supply)=20
where a and b and diesel_cost_litres are constants.

I can predetermine the "diesel_generator_capacity" value, but this would re=
present the maximum value that the "diesel_supply" could ever reach (and do=
esn't necessarily have to reach).

I think that what I am trying to achieve is quite complex since I cannot re=
plicate the 24x1 vector which has known elements of PV_supply and WT_supply=
for Diesel_supply since I am trying for the code to output not only the "D=
iesel_supply" values but also the number of units (x3).

Else

It may be simpler to say that I am going to predetermine the number of unit=
s of diesel i.e. set x3 =3D 1 with again a predetermined value of "diesel_g=
enerator_capacity" (say 200kW).
In that case I will only have the "diesel_supply" unknown (from the new equ=
ation in this post)
and some how that way minimise the "Diesel_cost" over the 24x1 values?

```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <e155ab0f-b3a4-46a4-94d6-0df95834f7a7@googlegroups.com>...
> Matt thank you for you help and sorry for the confusion but I have come across a new equation that may help
>
> remember that I am trying to optimise the cost function "f". The problem I have is that I know the values in the vector "PV_supply" and "WT_supply" of which I am looking for the number of units as (x1 an x2) but I don't know the values in "Diesel_supply" which i am of course trying to find out (as well as the number of units)
>
> I have come across the equation
>
> Diesel_cost = diesel_cost_litres*( b*diesel_generator_capacity + a*diesel_supply)
> where a and b and diesel_cost_litres are constants.
>
> I can predetermine the "diesel_generator_capacity" value, but this would represent the maximum value that the "diesel_supply" could ever reach (and doesn't necessarily have to reach).
>
> I think that what I am trying to achieve is quite complex since I cannot replicate the 24x1 vector which has known elements of PV_supply and WT_supply for Diesel_supply since I am trying for the code to output not only the "Diesel_supply" values but also the number of units (x3).
>
> Else
>
> It may be simpler to say that I am going to predetermine the number of units of diesel i.e. set x3 = 1 with again a predetermined value of "diesel_generator_capacity" (say 200kW).
> In that case I will only have the "diesel_supply" unknown (from the new equation in this post)
> and some how that way minimise the "Diesel_cost" over the 24x1 values?
================

Hi Andrew, I think I need to emphasize something to make discussion easier. We, the Newsgroup, do not understand your application at all and aren't going to. The only thing that's going to be clear to us is a mathematical formulation of what you are trying to achieve, similar to what I gave in my last post and which I've reproduced below. If you've come across new information, the only thing that's going to help us understand what's going on is if you now rewrite the description of the optimization problem (in the same general form as below) to show us how that new information changes the problem.

min f(z)*x

subject to constraints

A(z)*x<=demand
a*z^2+(b-1)*z+c=0
```
 0
Reply mattjacREMOVE (3190) 7/8/2012 8:05:07 PM

```Hi Matt

Yes you are right, I do sometimes assume that people know what I am talking=
about in the physical sense and will try and focus more on the mathematica=
l representation - apologies for this.

So to rewrite my previous question :=20

I have the following code:

Diesel_cost =3D sum(Diesel_supply*0.4);

A =3D [-PV_supply -WT_supply -Diesel_supply ];
b =3D -Demand;=20
f =3D [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Diesel_=
cost];=20
[x,fval,exitflag] =3D linprog(f,A,b)

Where PV_supply and WT_supply and Diesel_supply are 24x1 and Demand is 24x1=
and so f =3D 3x1.

Where I am struggling is with the fact that I have too many unknown variabl=
es. This is because the values in PV_supply and WT_supply vectors are given=
to me but the diesel_supply values are not (even though I have shown it in=
"A") I am just trying to optimise the number of units equivalent to x1,x2 =
and x3, but in the case of Diesel_supply I don't even know the values in th=
e vector.

What I do know is the following:
Demand - PV_supply*x1 - WT_supply*x2 <=3D Diesel_supply*x3

Therefore I am looking for the optimum "Diesel_supply" which all I know is =
the size of (i.e 24x1) and I could assume a max(Diesel_supply) value (e.g 2=
00) if this was to help.
=20
Also I have come across the equation below that represent the "diesel_suppl=
y" variable with the "Diesel_cost" variable shown in the inequality matrix =
"A" and objective function "f" respectively.=20

Diesel_cost =3D Diesel_cost_litres * ( b*diesel_generator_capacity + a*dies=
el_supply)=20

Where a and b and scalar constants and the "diesel_supply" in the equation =
above is the same as the "diesel_supply" in the objective function "f" and =
I could again fix the "diesel_generator"capacity" to a value of my choice a=
gain say 200 and "Diesel_cost_litres" is =3D 0.4.=20

Therefore, from the equation above, only the "diesel_supply" variable is un=
known and should be varying across each of the 24 values of the data set.

I hope this post articulates a much clearer image of my problem and the fac=
t that I seem to have something like an "implicit function" when it comes t=
o the "Diesel_supply" variable since I am hoping to construct a code that w=
ill propose the element value of each of the 24 elements of the "Diesel_sup=
ply" and well as the optimum number of units - which is represented by x3.

thank you
```
 0

```Hi Matt

Yes you are right, I do sometimes assume that people know what I am talking=
about in the physical sense and will try and focus more on the mathematica=
l representation - apologies for this.

So to rewrite my previous question :=20

I have the following code:

Diesel_cost =3D sum(Diesel_supply*0.4);

A =3D [-PV_supply -WT_supply -Diesel_supply ];
b =3D -Demand;=20
f =3D [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Diesel_=
cost];=20
[x,fval,exitflag] =3D linprog(f,A,b)

Where PV_supply and WT_supply and Diesel_supply are 24x1 and Demand is 24x1=
and so f =3D 3x1.

Where I am struggling is with the fact that I have too many unknown variabl=
es. This is because the values in PV_supply and WT_supply vectors are given=
to me but the diesel_supply values are not (even though I have shown it in=
"A") I am just trying to optimise the number of units equivalent to x1,x2 =
and x3, but in the case of Diesel_supply I don't even know the values in th=
e vector.

What I do know is the following:
Demand - PV_supply*x1 - WT_supply*x2 <=3D Diesel_supply*x3

Therefore I am looking for the optimum "Diesel_supply" which all I know is =
the size of (i.e 24x1) and I could assume a max(Diesel_supply) value (e.g 2=
00) if this was to help.
=20
Also I have come across the equation below that represent the "diesel_suppl=
y" variable with the "Diesel_cost" variable shown in the inequality matrix =
"A" and objective function "f" respectively.=20

Diesel_cost =3D Diesel_cost_litres * ( b*diesel_generator_capacity + a*dies=
el_supply)=20

Where a and b and scalar constants and the "diesel_supply" in the equation =
above is the same as the "diesel_supply" in the objective function "f" and =
I could again fix the "diesel_generator"capacity" to a value of my choice a=
gain say 200 and "Diesel_cost_litres" is =3D 0.4.=20

Therefore, from the equation above, only the "diesel_supply" variable is un=
known and should be varying across each of the 24 values of the data set.

I hope this post articulates a much clearer image of my problem and the fac=
t that I seem to have something like an "implicit function" when it comes t=
o the "Diesel_supply" variable since I am hoping to construct a code that w=
ill propose the element value of each of the 24 elements of the "Diesel_sup=
ply" and well as the optimum number of units - which is represented by x3.

thank you
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <5a9cf315-eae7-409d-8ab9-19969a381237@googlegroups.com>...
> Hi Matt
>
> Yes you are right, I do sometimes assume that people know what I am talking about in the physical sense and will try and focus more on the mathematical representation - apologies for this.
>
> So to rewrite my previous question :
>
> I have the following code:
>
> Diesel_cost = sum(Diesel_supply*0.4);
>
> A = [-PV_supply -WT_supply -Diesel_supply ];
> b = -Demand;
> f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Diesel_cost];
> [x,fval,exitflag] = linprog(f,A,b)
>
> Where PV_supply and WT_supply and Diesel_supply are 24x1 and Demand is 24x1 and so f = 3x1.
>
> Where I am struggling is with the fact that I have too many unknown variables. This is because the values in PV_supply and WT_supply vectors are given to me but the diesel_supply values are not (even though I have shown it in "A") I am just trying to optimise the number of units equivalent to x1,x2 and x3, but in the case of Diesel_supply I don't even know the values in the vector.
>
> What I do know is the following:
> Demand - PV_supply*x1 - WT_supply*x2 <= Diesel_supply*x3
>
> Therefore I am looking for the optimum "Diesel_supply" which all I know is the size of (i.e 24x1) and I could assume a max(Diesel_supply) value (e.g 200) if this was to help.
>
> Also I have come across the equation below that represent the "diesel_supply" variable with the "Diesel_cost" variable shown in the inequality matrix "A" and objective function "f" respectively.
>
> Diesel_cost = Diesel_cost_litres * ( b*diesel_generator_capacity + a*diesel_supply)
>
> Where a and b and scalar constants and the "diesel_supply" in the equation above is the same as the "diesel_supply" in the objective function "f" and I could again fix the "diesel_generator"capacity" to a value of my choice again say 200 and "Diesel_cost_litres" is = 0.4.
>
> Therefore, from the equation above, only the "diesel_supply" variable is unknown and should be varying across each of the 24 values of the data set.
>
> I hope this post articulates a much clearer image of my problem and the fact that I seem to have something like an "implicit function" when it comes to the "Diesel_supply" variable since I am hoping to construct a code that will propose the element value of each of the 24 elements of the "Diesel_supply" and well as the optimum number of units - which is represented by x3.
===========

Yes, this is clearer. The solution is probably to introduce a 4th unknown variable x4 where

x4=diesel_supply*x3

This will let you rewrite your original linear program as a linear program in the 4 variables x1...x4. In particular, if you substitute your equation

Diesel_cost = Diesel_cost_litres * ( b*diesel_generator_capacity + a*diesel_supply)

into the equation for f

f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Diesel_cost];

then you will see that you get a new linear objective function in the 4 unknowns x1...x4

Your linear constraints get modified in a similar way and will lead to a constraint matrix A  that is now Nx4.
```
 0
Reply mattjacREMOVE (3190) 7/9/2012 4:14:07 PM

```hi=20

On Monday, 9 July 2012 17:14:07 UTC+1, Matt J   wrote:
> > Hi Matt
> >=20
> > Yes you are right, I do sometimes assume that people know what I am tal=
king about in the physical sense and will try and focus more on the mathema=
tical representation - apologies for this.
> >=20
> > So to rewrite my previous question :=20
> >=20
> > I have the following code:
> >=20
> > Diesel_cost =3D sum(Diesel_supply*0.4);
> >=20
> > A =3D [-PV_supply -WT_supply -Diesel_supply ];
> > b =3D -Demand;=20
> > f =3D [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Die=
sel_cost];=20
> > [x,fval,exitflag] =3D linprog(f,A,b)
> >=20
> > Where PV_supply and WT_supply and Diesel_supply are 24x1 and Demand is =
24x1 and so f =3D 3x1.
> >=20
> > Where I am struggling is with the fact that I have too many unknown var=
iables. This is because the values in PV_supply and WT_supply vectors are g=
iven to me but the diesel_supply values are not (even though I have shown i=
t in "A") I am just trying to optimise the number of units equivalent to x1=
,x2 and x3, but in the case of Diesel_supply I don't even know the values i=
n the vector.
> >=20
> > What I do know is the following:
> > Demand - PV_supply*x1 - WT_supply*x2 <=3D Diesel_supply*x3
> >=20
> > Therefore I am looking for the optimum "Diesel_supply" which all I know=
is the size of (i.e 24x1) and I could assume a max(Diesel_supply) value (e=
..g 200) if this was to help.
> > =20
> > Also I have come across the equation below that represent the "diesel_s=
upply" variable with the "Diesel_cost" variable shown in the inequality mat=
rix "A" and objective function "f" respectively.=20
> >=20
> > Diesel_cost =3D Diesel_cost_litres * ( b*diesel_generator_capacity + a*=
diesel_supply)=20
> >=20
> > Where a and b and scalar constants and the "diesel_supply" in the equat=
ion above is the same as the "diesel_supply" in the objective function "f" =
and I could again fix the "diesel_generator"capacity" to a value of my choi=
ce again say 200 and "Diesel_cost_litres" is =3D 0.4.=20
> >=20
> > Therefore, from the equation above, only the "diesel_supply" variable i=
s unknown and should be varying across each of the 24 values of the data se=
t.
> >=20
> > I hope this post articulates a much clearer image of my problem and the=
fact that I seem to have something like an "implicit function" when it com=
es to the "Diesel_supply" variable since I am hoping to construct a code th=
at will propose the element value of each of the 24 elements of the "Diesel=
_supply" and well as the optimum number of units - which is represented by =
x3.
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Yes, this is clearer. The solution is probably to introduce a 4th unknown=
variable x4 where
>=20
> x4=3Ddiesel_supply*x3
>=20
> This will let you rewrite your original linear program as a linear progra=
m in the 4 variables x1...x4. In particular, if you substitute your equatio=
n
>=20
> Diesel_cost =3D Diesel_cost_litres * ( b*diesel_generator_capacity + a*di=
esel_supply)=20
>=20
> into the equation for f
>=20
>  f =3D [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+Dies=
el_cost];=20
>=20
> then you will see that you get a new linear objective function in the 4 u=
nknowns x1...x4
>=20
> Your linear constraints get modified in a similar way and will lead to a =
constraint matrix A  that is now Nx4.

Hi Matt

I am not quite sure I have understood your suggestions entirely and have li=
sted a couple of points below which I hope will help asking my question

1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, if x(3=
) is an unknown that linprog should output, how can I compute such a comman=
d?
Also, I am trying to output the "diesel_supply" vector so how can I comput=
e these unknowns for x(4) since your suggested x(4) seems to be my proposed=
x(3), therefore what will the new x(3) represent?

2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres * ( b*=
diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't the "=
diesel_supply" vector unknown that we are trying to output as a solution (a=
s well as optimum x1,x2 etc)

3) Also, how can I expand the matrix "A" to include the x(4) - maybe this w=
ill be clearer to me once I understand your suggestions

Thank you
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <7ab5575a-8e35-4903-b822-b95ec3b12757@googlegroups.com>...
>
>
> I am not quite sure I have understood your suggestions entirely and have listed a couple of points below which I hope will help asking my question
>
> 1) You mentioned introducing an  x(4)=diesel_supply*x(3). However, if x(3) is an unknown that linprog should output, how can I compute such a command?
=========

What I'm saying is this. If you write out explicit expressions for the constraints A*x(1:3) and objective function f*x(1:3), you will see that they all depend on diesel_supply only through the expression "diesel_supply*x(3)". So, you should simply define this expression as an additional unknown x(4). If you then go through the expressions for your objective/constraints and replace every occurrence of "diesel_supply*x(3)" with the new variable x(4), you will find that you have a new linear program in 4 variables x(1)...x(4).

>  Also, I am trying to output the "diesel_supply" vector so how can I compute these unknowns for x(4) since your suggested x(4) seems to be my proposed x(3), therefore what will the new x(3) represent?
=============

Once you use linprog to solve for x(3) and x(4), you can recover diesel_supply by solving

x(4)=diesel_supply*x(3)

> 2) You mentioned to substitute "> Diesel_cost = Diesel_cost_litres * ( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't the "diesel_supply" vector unknown that we are trying to output as a solution (as well as optimum x1,x2 etc)
==========

Yes, but why does that matter? Whenever you write down any equation, it will consist of some quantities that are known and some that are unknown.

> 3) Also, how can I expand the matrix "A" to include the x(4) - maybe this will be clearer to me once I understand your suggestions
========

Once you write down the expression for A*x(1:3) as individual inequalities and make the substitution x(4) diesel_supply*x(3) you will have expressions for a new set of linear inequalities, this time in 4 variables. Just organize the coefficients of these 4 variables into a new 4-column matrix A.
```
 0
Reply mattjacREMOVE (3190) 7/9/2012 5:28:18 PM

```On Monday, 9 July 2012 18:28:18 UTC+1, Matt J   wrote:
> >
> >=20
> > I am not quite sure I have understood your suggestions entirely and hav=
e listed a couple of points below which I hope will help asking my question
> >=20
> > 1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, if=
x(3) is an unknown that linprog should output, how can I compute such a co=
mmand?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> What I'm saying is this. If you write out explicit expressions for the co=
nstraints A*x(1:3) and objective function f*x(1:3), you will see that they =
all depend on diesel_supply only through the expression "diesel_supply*x(3)=
". So, you should simply define this expression as an additional unknown x(=
4). If you then go through the expressions for your objective/constraints a=
nd replace every occurrence of "diesel_supply*x(3)" with the new variable x=
(4), you will find that you have a new linear program in 4 variables x(1)..=
..x(4).
>=20
>=20
> >  Also, I am trying to output the "diesel_supply" vector so how can I co=
mpute these unknowns for x(4) since your suggested x(4) seems to be my prop=
osed x(3), therefore what will the new x(3) represent?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Once you use linprog to solve for x(3) and x(4), you can recover diesel_s=
upply by solving
>=20
> x(4)=3Ddiesel_supply*x(3)
>=20
>=20
> =20
> > 2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres * =
( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't t=
he "diesel_supply" vector unknown that we are trying to output as a solutio=
n (as well as optimum x1,x2 etc)
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Yes, but why does that matter? Whenever you write down any equation, it w=
ill consist of some quantities that are known and some that are unknown.
>=20
>=20
> > 3) Also, how can I expand the matrix "A" to include the x(4) - maybe th=
is will be clearer to me once I understand your suggestions
> =3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Once you write down the expression for A*x(1:3) as individual inequalitie=
s and make the substitution x(4) diesel_supply*x(3) you will have expressio=
ns for a new set of linear inequalities, this time in 4 variables. Just org=
anize the coefficients of these 4 variables into a new 4-column matrix A.

Matt - I am afraid I still don't understand the thought behind your suggest=
ion. This is mainly because I can't see the solution to the inequality say =
for first row of "A" which is
PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D Dema=
nd (1,1).
At this stage what the complexity involved is that there is no definition f=
or the "Diesel_supply" component of "A". All I know is the size.
Therefore not only am I trying to optimise the x's using the coefficients, =
in this case I don't actually have any coefficients for the "Diesel_supply"=
component.
In that sense, I am struggling to see how if I add a fourth variable, I wil=
l get a result that makes physical sense as well.
```
 0

```On Monday, 9 July 2012 19:40:30 UTC+1, Andrew Alkiviades  wrote:
> On Monday, 9 July 2012 18:28:18 UTC+1, Matt J   wrote:
> > >
> > >=20
> > > I am not quite sure I have understood your suggestions entirely and h=
ave listed a couple of points below which I hope will help asking my questi=
on
> > >=20
> > > 1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, =
if x(3) is an unknown that linprog should output, how can I compute such a =
command?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > What I'm saying is this. If you write out explicit expressions for the =
constraints A*x(1:3) and objective function f*x(1:3), you will see that the=
y all depend on diesel_supply only through the expression "diesel_supply*x(=
3)". So, you should simply define this expression as an additional unknown =
x(4). If you then go through the expressions for your objective/constraints=
and replace every occurrence of "diesel_supply*x(3)" with the new variable=
x(4), you will find that you have a new linear program in 4 variables x(1)=
....x(4).
> >=20
> >=20
> > >  Also, I am trying to output the "diesel_supply" vector so how can I =
compute these unknowns for x(4) since your suggested x(4) seems to be my pr=
oposed x(3), therefore what will the new x(3) represent?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you use linprog to solve for x(3) and x(4), you can recover diesel=
_supply by solving
> >=20
> > x(4)=3Ddiesel_supply*x(3)
> >=20
> >=20
> > =20
> > > 2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres =
* ( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't=
the "diesel_supply" vector unknown that we are trying to output as a solut=
ion (as well as optimum x1,x2 etc)
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Yes, but why does that matter? Whenever you write down any equation, it=
will consist of some quantities that are known and some that are unknown.
> >=20
> >=20
> > > 3) Also, how can I expand the matrix "A" to include the x(4) - maybe =
this will be clearer to me once I understand your suggestions
> > =3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you write down the expression for A*x(1:3) as individual inequalit=
ies and make the substitution x(4) diesel_supply*x(3) you will have express=
ions for a new set of linear inequalities, this time in 4 variables. Just o=
rganize the coefficients of these 4 variables into a new 4-column matrix A.
>=20
> Matt - I am afraid I still don't understand the thought behind your sugge=
stion. This is mainly because I can't see the solution to the inequality sa=
y for first row of "A" which is
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D De=
mand (1,1).
> At this stage what the complexity involved is that there is no definition=
for the "Diesel_supply" component of "A". All I know is the size.
> Therefore not only am I trying to optimise the x's using the coefficients=
, in this case I don't actually have any coefficients for the "Diesel_suppl=
y" component.
> In that sense, I am struggling to see how if I add a fourth variable, I w=
ill get a result that makes physical sense as well.

On Monday, 9 July 2012 19:40:30 UTC+1, Andrew Alkiviades  wrote:
> On Monday, 9 July 2012 18:28:18 UTC+1, Matt J   wrote:
> > >
> > >=20
> > > I am not quite sure I have understood your suggestions entirely and h=
ave listed a couple of points below which I hope will help asking my questi=
on
> > >=20
> > > 1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, =
if x(3) is an unknown that linprog should output, how can I compute such a =
command?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > What I'm saying is this. If you write out explicit expressions for the =
constraints A*x(1:3) and objective function f*x(1:3), you will see that the=
y all depend on diesel_supply only through the expression "diesel_supply*x(=
3)". So, you should simply define this expression as an additional unknown =
x(4). If you then go through the expressions for your objective/constraints=
and replace every occurrence of "diesel_supply*x(3)" with the new variable=
x(4), you will find that you have a new linear program in 4 variables x(1)=
....x(4).
> >=20
> >=20
> > >  Also, I am trying to output the "diesel_supply" vector so how can I =
compute these unknowns for x(4) since your suggested x(4) seems to be my pr=
oposed x(3), therefore what will the new x(3) represent?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you use linprog to solve for x(3) and x(4), you can recover diesel=
_supply by solving
> >=20
> > x(4)=3Ddiesel_supply*x(3)
> >=20
> >=20
> > =20
> > > 2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres =
* ( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't=
the "diesel_supply" vector unknown that we are trying to output as a solut=
ion (as well as optimum x1,x2 etc)
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Yes, but why does that matter? Whenever you write down any equation, it=
will consist of some quantities that are known and some that are unknown.
> >=20
> >=20
> > > 3) Also, how can I expand the matrix "A" to include the x(4) - maybe =
this will be clearer to me once I understand your suggestions
> > =3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you write down the expression for A*x(1:3) as individual inequalit=
ies and make the substitution x(4) diesel_supply*x(3) you will have express=
ions for a new set of linear inequalities, this time in 4 variables. Just o=
rganize the coefficients of these 4 variables into a new 4-column matrix A.
>=20
> Matt - I am afraid I still don't understand the thought behind your sugge=
stion. This is mainly because I can't see the solution to the inequality sa=
y for first row of "A" which is
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D De=
mand (1,1).
> At this stage what the complexity involved is that there is no definition=
for the "Diesel_supply" component of "A". All I know is the size.
> Therefore not only am I trying to optimise the x's using the coefficients=
, in this case I don't actually have any coefficients for the "Diesel_suppl=
y" component.
> In that sense, I am struggling to see how if I add a fourth variable, I w=
ill get a result that makes physical sense as well.

On Monday, 9 July 2012 19:40:30 UTC+1, Andrew Alkiviades  wrote:
> On Monday, 9 July 2012 18:28:18 UTC+1, Matt J   wrote:
> > >
> > >=20
> > > I am not quite sure I have understood your suggestions entirely and h=
ave listed a couple of points below which I hope will help asking my questi=
on
> > >=20
> > > 1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, =
if x(3) is an unknown that linprog should output, how can I compute such a =
command?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > What I'm saying is this. If you write out explicit expressions for the =
constraints A*x(1:3) and objective function f*x(1:3), you will see that the=
y all depend on diesel_supply only through the expression "diesel_supply*x(=
3)". So, you should simply define this expression as an additional unknown =
x(4). If you then go through the expressions for your objective/constraints=
and replace every occurrence of "diesel_supply*x(3)" with the new variable=
x(4), you will find that you have a new linear program in 4 variables x(1)=
....x(4).
> >=20
> >=20
> > >  Also, I am trying to output the "diesel_supply" vector so how can I =
compute these unknowns for x(4) since your suggested x(4) seems to be my pr=
oposed x(3), therefore what will the new x(3) represent?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you use linprog to solve for x(3) and x(4), you can recover diesel=
_supply by solving
> >=20
> > x(4)=3Ddiesel_supply*x(3)
> >=20
> >=20
> > =20
> > > 2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres =
* ( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't=
the "diesel_supply" vector unknown that we are trying to output as a solut=
ion (as well as optimum x1,x2 etc)
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Yes, but why does that matter? Whenever you write down any equation, it=
will consist of some quantities that are known and some that are unknown.
> >=20
> >=20
> > > 3) Also, how can I expand the matrix "A" to include the x(4) - maybe =
this will be clearer to me once I understand your suggestions
> > =3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you write down the expression for A*x(1:3) as individual inequalit=
ies and make the substitution x(4) diesel_supply*x(3) you will have express=
ions for a new set of linear inequalities, this time in 4 variables. Just o=
rganize the coefficients of these 4 variables into a new 4-column matrix A.
>=20
> Matt - I am afraid I still don't understand the thought behind your sugge=
stion. This is mainly because I can't see the solution to the inequality sa=
y for first row of "A" which is
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D De=
mand (1,1).
> At this stage what the complexity involved is that there is no definition=
for the "Diesel_supply" component of "A". All I know is the size.
> Therefore not only am I trying to optimise the x's using the coefficients=
, in this case I don't actually have any coefficients for the "Diesel_suppl=
y" component.
> In that sense, I am struggling to see how if I add a fourth variable, I w=
ill get a result that makes physical sense as well.

On Monday, 9 July 2012 19:40:30 UTC+1, Andrew Alkiviades  wrote:
> On Monday, 9 July 2012 18:28:18 UTC+1, Matt J   wrote:
> > >
> > >=20
> > > I am not quite sure I have understood your suggestions entirely and h=
ave listed a couple of points below which I hope will help asking my questi=
on
> > >=20
> > > 1) You mentioned introducing an  x(4)=3Ddiesel_supply*x(3). However, =
if x(3) is an unknown that linprog should output, how can I compute such a =
command?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > What I'm saying is this. If you write out explicit expressions for the =
constraints A*x(1:3) and objective function f*x(1:3), you will see that the=
y all depend on diesel_supply only through the expression "diesel_supply*x(=
3)". So, you should simply define this expression as an additional unknown =
x(4). If you then go through the expressions for your objective/constraints=
and replace every occurrence of "diesel_supply*x(3)" with the new variable=
x(4), you will find that you have a new linear program in 4 variables x(1)=
....x(4).
> >=20
> >=20
> > >  Also, I am trying to output the "diesel_supply" vector so how can I =
compute these unknowns for x(4) since your suggested x(4) seems to be my pr=
oposed x(3), therefore what will the new x(3) represent?
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you use linprog to solve for x(3) and x(4), you can recover diesel=
_supply by solving
> >=20
> > x(4)=3Ddiesel_supply*x(3)
> >=20
> >=20
> > =20
> > > 2) You mentioned to substitute "> Diesel_cost =3D Diesel_cost_litres =
* ( b*diesel_generator_capacity + a*diesel_supply) " in "f". However, isn't=
the "diesel_supply" vector unknown that we are trying to output as a solut=
ion (as well as optimum x1,x2 etc)
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Yes, but why does that matter? Whenever you write down any equation, it=
will consist of some quantities that are known and some that are unknown.
> >=20
> >=20
> > > 3) Also, how can I expand the matrix "A" to include the x(4) - maybe =
this will be clearer to me once I understand your suggestions
> > =3D=3D=3D=3D=3D=3D=3D=3D
> >=20
> > Once you write down the expression for A*x(1:3) as individual inequalit=
ies and make the substitution x(4) diesel_supply*x(3) you will have express=
ions for a new set of linear inequalities, this time in 4 variables. Just o=
rganize the coefficients of these 4 variables into a new 4-column matrix A.
>=20
> Matt - I am afraid I still don't understand the thought behind your sugge=
stion. This is mainly because I can't see the solution to the inequality sa=
y for first row of "A" which is
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D De=
mand (1,1).
> At this stage what the complexity involved is that there is no definition=
for the "Diesel_supply" component of "A". All I know is the size.
> Therefore not only am I trying to optimise the x's using the coefficients=
, in this case I don't actually have any coefficients for the "Diesel_suppl=
y" component.
> In that sense, I am struggling to see how if I add a fourth variable, I w=
ill get a result that makes physical sense as well.

```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <8e8cd549-2b6f-437d-bfed-4aa56b2bbff3@googlegroups.com>...
>
>
> Matt - I am afraid I still don't understand the thought behind your suggestion. This is mainly because I can't see the solution to the inequality say for first row of "A" which is
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >= Demand (1,1).
> At this stage what the complexity involved is that there is no definition for the "Diesel_supply" component of "A". All I know is the size.
=============

Preliminary remark - I'm assuming that diesel_supply is a scalar. If not, this conflicts with other information you've given. In the formula you gave for f, diesel_cost played the role of a scalar and in the formula you gave for diesel_cost, diesel_supply played the role of a scalar as well. If you're now telling me diesel_supply is a vector, the sizes of other things in your problem are now inconsistent with each other.

> Therefore not only am I trying to optimise the x's using the coefficients, in this case I don't actually have any coefficients for the "Diesel_supply" component.
=============

You keep referring to diesel_supply as a "coefficient". You should stop that. Since diesel_supply is apriori unknown, you need to stop thinking of it as a coefficient and start thinking of it as yet another unknown variable that you need to solve for, just like x(1), x(2), x(3).

Also, you should realize that when you multiply 2 unknowns together, you get another unknown. So, instead of solving for x(1), x(2), x(3), and Diesel_supply, I propose that we solve for the four quantities x(1), x(2), x(3), and Diesel_supply*x(3). Furthermore, I propose that we relabel the quantity Diesel_supply*x(3) as a new variable x(4). There is no loss of information if we do this. There are 4 degrees of freedom no matter how we label the unknowns.

If we do this relabeling, then your first inequality above can be rewritten

PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+ 0*x(3) + 1*x(4) >= Demand (1,1).

That is, your 4 coefficients in the equality are now

PV_supply(1,1)
WT_supply(1,1)
0
1

The slight problem this reveals is that since the coefficient of x(3) is now always zero, then x(3) is now unconstrained. You need to provide additional information on x(3) so that it will be well-specified in this 4 dimensional problem.

However, that was inevitable. Because you've added a 4th degree of freedom, whether you call it diesel_supply or x(4), you need extra information to specify it.
```
 0
Reply mattjacREMOVE (3190) 7/9/2012 7:49:26 PM

```On Monday, 9 July 2012 20:49:26 UTC+1, Matt J   wrote:
> >
> >=20
> > Matt - I am afraid I still don't understand the thought behind your sug=
gestion. This is mainly because I can't see the solution to the inequality =
say for first row of "A" which is
> > PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+Diesel_supply(1,1)*x(3) >=3D =
Demand (1,1).
> > At this stage what the complexity involved is that there is no definiti=
on for the "Diesel_supply" component of "A". All I know is the size.
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Preliminary remark - I'm assuming that diesel_supply is a scalar. If not,=
this conflicts with other information you've given. In the formula you gav=
e for f, diesel_cost played the role of a scalar and in the formula you gav=
e for diesel_cost, diesel_supply played the role of a scalar as well. If yo=
u're now telling me diesel_supply is a vector, the sizes of other things in=
your problem are now inconsistent with each other.
>=20
>=20
>=20
> > Therefore not only am I trying to optimise the x's using the coefficien=
ts, in this case I don't actually have any coefficients for the "Diesel_sup=
ply" component.
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> You keep referring to diesel_supply as a "coefficient". You should stop t=
hat. Since diesel_supply is apriori unknown, you need to stop thinking of i=
t as a coefficient and start thinking of it as yet another unknown variable=
that you need to solve for, just like x(1), x(2), x(3).
>=20
> Also, you should realize that when you multiply 2 unknowns together, you =
get another unknown. So, instead of solving for x(1), x(2), x(3), and Diese=
l_supply, I propose that we solve for the four quantities x(1), x(2), x(3),=
and Diesel_supply*x(3). Furthermore, I propose that we relabel the quantit=
y Diesel_supply*x(3) as a new variable x(4). There is no loss of informatio=
n if we do this. There are 4 degrees of freedom no matter how we label the =
unknowns.
>=20
> If we do this relabeling, then your first inequality above can be rewritt=
en
>=20
> PV_supply(1,1)*x(1) + WT_supply(1,1)*x(2)+ 0*x(3) + 1*x(4) >=3D Demand (1=
,1).
>=20
> That is, your 4 coefficients in the equality are now
> =20
> PV_supply(1,1)
> WT_supply(1,1)
> 0
> 1
>=20
> The slight problem this reveals is that since the coefficient of x(3) is =
now always zero, then x(3) is now unconstrained. You need to provide additi=
onal information on x(3) so that it will be well-specified in this 4 dimens=
ional problem.=20
>=20
> However, that was inevitable. Because you've added a 4th degree of freedo=
m, whether you call it diesel_supply or x(4), you need extra information to=
specify it.

Matt
Apologies for the confusion but as I have said in my previous posts, "Diese=
l_supply" is a vector which has the same size as PV_supply and WT_supply.=
=20

The reason I am saying about the coefficients is because the x's represent =
the "number of units" of a certain technology. The three values shown in "f=
" are scalars.
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <514a30be-e21a-4fef-81dd-87e7d9c0f926@googlegroups.com>...
>
>
> Matt
> Apologies for the confusion but as I have said in my previous posts, "Diesel_supply" is a vector which has the same size as PV_supply and WT_supply.
>...The three values shown in "f" are scalars.
==================

If so, then I say again, that creates inconsistencies. If f indeed contains 3 scalars, then Diesel_cost has to be a scalar in your expression below

f = [CRF_PV*CC_PV; CRF_WT*CC_WT;(CRF_Diesel_generator*CC_Diesel)+Diesel_cost];

If we agree that Diesel_cost is a scalar, then diesel_supply has to be a scalar in this next definition,

Diesel_cost = Diesel_cost_litres * ( b*diesel_generator_capacity + a*diesel_supply)

since you've said everything else in it this definition is a scalar.

So, am I to conclude there is a difference between the quantity you have labelled "diesel_supply" with a lower-case d and "Diesel_supply" with an uppercase D?

> The reason I am saying about the coefficients is because the x's represent the "number of units" of a certain technology.
=================

That might be your reason, but it's irrelevant to the point I was making. The point was that Diesel_supply has to be treated like an unknown variable to be solved for (because it is).

Even if Diesel_supply is a vector, my remarks from before may still apply. The quantity Diesel_supply*x(3) can be treated as a vector of additional unknown variables [x(4)....x(N)] and the dependence of the constraints on these new variables is still linear. If you can come up with additional linear constraints to deal with the new degrees of freedom that this introduces, you may be able to use LINPROG to solve for all N variables.
```
 0
Reply mattjacREMOVE (3190) 7/9/2012 8:25:21 PM

```Matt

Yes the diesel_cost is a scalar that is the sum of all the diesel_supply va=
lues multiplied by a constant. There is no differentiation between upper an=
d lower case characters.=20
diesel_supply is the 24x1 vector of unknown values (as well as unknown x3 e=
tc..

the  equation:
diesel_cost =3D diesel_cost_litres * ( b*diesel_generator_capacity + a*dies=
el_supply)  is only implemented for each value of the 24 rows. therefore I =
should in fact introduce a new variable as say "total_diesel_cost" , where =
total_diesel_cost =3D sum(diesel_cost)  that is then substituted to the obj=
ective function "f" vector - my apologies.

I think  I have been a little confused with the x(4)...x(N) notation as I a=
ctually have the unknown values say "diesel_1 ... Diesel_N as well as the "=
diesel_supply" vector =3D [diesel_1*x(3); diesel_2*x(4)...diesel_N*x(N) etc=
] right?

Also, regarding the added constraints you mentioned, are these necessary?

Could you possibly show me one line of how the a matrix would look like wit=

Thank you

```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <377cc6a2-3ee5-4c0b-a6b4-565b6eae9d25@googlegroups.com>...
>
> I think  I have been a little confused with the x(4)...x(N) notation as I actually have the unknown values say "diesel_1 ... Diesel_N as well as the "diesel_supply" vector = [diesel_1*x(3); diesel_2*x(4)...diesel_N*x(N) etc] right?
===========

Don't know where that came from. I don't think you've mentioned diesel_1..diesel_N before.

> Also, regarding the added constraints you mentioned, are these necessary?
============

Well, you have 26 unknowns in total. You therefore probably need at least that many constraints. Currently, you're only imposing 24.

> Could you possibly show me one line of how the a matrix would look like with your suggestion?
==============

The first line of the matrix will look the same as I described 2 posts ago.
The second line will look the same except with x(5) instead of x(4), etc...
```
 0
Reply mattjacREMOVE (3190) 7/9/2012 10:00:10 PM

```On Monday, 9 July 2012 23:00:10 UTC+1, Matt J   wrote:
> &gt;
> &gt; I think  I have been a little confused with the x(4)...x(N) notation=
as I actually have the unknown values say &quot;diesel_1 ... Diesel_N as w=
ell as the &quot;diesel_supply&quot; vector =3D [diesel_1*x(3); diesel_2*x(=
4)...diesel_N*x(N) etc] right?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Don&#39;t know where that came from. I don&#39;t think you&#39;ve mention=
ed diesel_1..diesel_N before.
>=20
>=20
> &gt; Also, regarding the added constraints you mentioned, are these neces=
sary?
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Well, you have 26 unknowns in total. You therefore probably need at least=
that many constraints. Currently, you&#39;re only imposing 24.
>=20
>=20
> &gt; Could you possibly show me one line of how the a matrix would look l=
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> The first line of the matrix will look the same as I described 2 posts ag=
o.
> The second line will look the same except with x(5) instead of x(4), etc.=
...

is this what you mean?
zero_test =3D zeros(24,1);
one_test =3D ones(24,1);
A =3D [-PV_supply -WT_supply zero_test -one_test ]; ?

I might take some time to understand what your suggestion is since I am rea=
lly not sure what you mean.=20
I am still not sure about how I can "overcome" the problem of having a vect=
or with unknown elements. I am also trying to understand how the code makes=
physical sense as well which I need to think about - this is also because =
the "diesel_cost" in the "f" should be accounted for in the minization and =
somehow represented in the constraints

Thank you for your help and patience and I will get back with more question=
s very soon!
```
 0

```Just a quick question to make sure

Is there any way of doing something like - or in the form of

A = [-PV_supply -WT_supply -Demand-(PV_supply*x(1)+WT_supply*x(2))]

where x(2) and x(3) are the outputs I am looking for?
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <dffc714f-4dcc-4e20-bf02-6dca5a993b8c@googlegroups.com>...
>
>
>Is there any way of doing something like - or in the form of
>
>A = [-PV_supply -WT_supply -Demand-(PV_supply*x(1)+WT_supply*x(2))]
>
>where x(2) and x(3) are the outputs I am looking for?
===============

No. In a linear program, the constraint coefficients in the A matrix have to be known constants. They cannot depend on your unknown variables.

> > The first line of the matrix will look the same as I described 2 posts ago.
> > The second line will look the same except with x(5) instead of x(4), etc...
>
> is this what you mean?
> zero_test = zeros(24,1);
>     one_test = ones(24,1);
> A = [-PV_supply -WT_supply zero_test -one_test ]; ?
==============

Sorry, there was a mistake in what I described to you earlier. The A matrix would really look like this

A = [-PV_supply, -WT_supply, zero_test, eye(24) ];

The resulting matrix should be 24x27 because you have 27 unknowns, consisting of the 24 unknown quantities associated with each Diesel_supply(j), j=1...24, plus
x1,x2,x3.

> I am still not sure about how I can "overcome" the problem of having a vector with unknown elements.
=============

Not sure why that's a "new problem". You've always had a vector of unknown elements consisting at the very least of [x1,x2,x3].

> I am also trying to understand how the code makes physical sense as well which I need to think about
===========

I myself am starting to think that you don't have enough physical information to solve the problem. According to what you've been telling me, you have 27 unknowns and very few constraints on them.

>this is also because the "diesel_cost" in the "f" should be accounted for in the minization and somehow represented in the constraints
=============

diesel_cost really shouldn't be in your f vector because it is a priori unknown. Similar to what I said above about A, the f vector must consist of apriori known constants.

```
 0
Reply mattjacREMOVE (3190) 7/10/2012 2:36:14 PM

```On Tuesday, 10 July 2012 15:36:14 UTC+1, Matt J   wrote:
> &gt;
> &gt;
> &gt;Is there any way of doing something like - or in the form of
> &gt;
> &gt;A = [-PV_supply -WT_supply -Demand-(PV_supply*x(1)+WT_supply*x(2))]
> &gt;
> &gt;where x(2) and x(3) are the outputs I am looking for?
> ===============
>
>
> No. In a linear program, the constraint coefficients in the A matrix have to be known constants. They cannot depend on your unknown variables.
>
>
>
> &gt; &gt; The first line of the matrix will look the same as I described 2 posts ago.
> &gt; &gt; The second line will look the same except with x(5) instead of x(4), etc...
> &gt;
> &gt; is this what you mean?
> &gt; zero_test = zeros(24,1);
> &gt;     one_test = ones(24,1);
> &gt; A = [-PV_supply -WT_supply zero_test -one_test ]; ?
> ==============
>
>
> Sorry, there was a mistake in what I described to you earlier. The A matrix would really look like this
>
> A = [-PV_supply, -WT_supply, zero_test, eye(24) ];
>
> The resulting matrix should be 24x27 because you have 27 unknowns, consisting of the 24 unknown quantities associated with each Diesel_supply(j), j=1...24, plus
> x1,x2,x3.
>
>
>
> &gt; I am still not sure about how I can &quot;overcome&quot; the problem of having a vector with unknown elements.
> =============
>
> Not sure why that&#39;s a &quot;new problem&quot;. You&#39;ve always had a vector of unknown elements consisting at the very least of [x1,x2,x3].
>
>
>
> &gt; I am also trying to understand how the code makes physical sense as well which I need to think about
> ===========
>
> I myself am starting to think that you don&#39;t have enough physical information to solve the problem. According to what you&#39;ve been telling me, you have 27 unknowns and very few constraints on them.
>
>
>
> &gt;this is also because the &quot;diesel_cost&quot; in the &quot;f&quot; should be accounted for in the minization and somehow represented in the constraints
> =============
>
> diesel_cost really shouldn&#39;t be in your f vector because it is a priori unknown. Similar to what I said above about A, the f vector must consist of apriori known constants.

Matt

Can  I make a suggestion and hear your feedback in light of some new info come across for this code.

Am a able to add a "floating " point for the actual value of the "diesel_supply" vector that is a component of the matrix "A"? ( sine this value is in fact unknown initially)

This is because I am now aware of a linear relationship between the "diesel_supply" column in "A" and "diesel_cost" scalar value in "f" (where diesel_cost = sum(hourly_diesel_cost))

In fact if I put some numbers to further explain.
"diesel_supply" is in column 1
"hourly_diesel_cost" is in column 2
0	0
10	44.619
20	45.918
30	47.217
40	48.516
50	49.815
60	51.114
70	52.413
80	53.712
90	55.011
100	56.31
110	57.609
120	58.908
130	60.207
140	61.506
150	62.805
160	64.104
170	65.403
180	66.702
190	68.001
200	69.3

Therefore not only am I trying to optimize for x(3) I am at the same time trying to find where the "diesel_supply" value must be sitting for each of the 24 hours in the data set

hope that makes sense?

I believe that some sort of iteration must be required for "diesel_supply" only - is it first of all possible to iterate only one column of the "A" matrix and was hoping for some help on this

I am interested to hear your thoughts on this

Thank you

```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <04881223-592b-4344-892e-dfd38c1b06bf@googlegroups.com>...
>
>
> Therefore not only am I trying to optimize for x(3) I am at the same time trying to find where the "diesel_supply" value must be sitting for each of the 24 hours in the data set
>
>
> hope that makes sense?
==========

Maybe. As far as I can understand it, you are now treating the diesel_supply values as unknowns, just as we've been discussing.

> I believe that some sort of iteration must be required for "diesel_supply" only - is it first of all possible to iterate only one column of the "A" matrix and was hoping for some help on this
>
> I am interested to hear your thoughts on this
============

Don't have any thoughts on this, I'm afraid. I don't see why you need to iterate over diesel_supply or give it any kind of separate treatment, especially since you now say you have additional linear constraints  to control it.
```
 0
Reply mattjacREMOVE (3190) 7/11/2012 6:25:12 PM

```On Wednesday, 11 July 2012 19:25:12 UTC+1, Matt J   wrote:
> &gt;
> &gt;
> &gt; Therefore not only am I trying to optimize for x(3) I am at the same time trying to find where the &quot;diesel_supply&quot; value must be sitting for each of the 24 hours in the data set
> &gt;
> &gt;
> &gt; hope that makes sense?
> ==========
>
> Maybe. As far as I can understand it, you are now treating the diesel_supply values as unknowns, just as we&#39;ve been discussing.
>
>
> &gt; I believe that some sort of iteration must be required for &quot;diesel_supply&quot; only - is it first of all possible to iterate only one column of the &quot;A&quot; matrix and was hoping for some help on this
> &gt;
> &gt; I am interested to hear your thoughts on this
> ============
>
> Don&#39;t have any thoughts on this, I&#39;m afraid. I don&#39;t see why you need to iterate over diesel_supply or give it any kind of separate treatment, especially since you now say you have additional linear constraints  to control it.

I think I need to iterate because the data set I copied above aren't  constraints - they are just an operating point and the respective cost

Diesel_supply = Diesel_matrix(:,1); % Power output of diesel generator
hourly_cost = Diesel_matrix(:,2);  % Diesel cost of running genreator at that output

for z = 1 : 21

A = [-PV_supply -WT_supply -Diesel_supply(z)];

f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  % how do we manipulate diesel cost?

b = -Demand;

[x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)

end

what I have tried above so far gives me an inconsistent matrix size since I think it is not looping correctly
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <607ba0c7-907f-473c-8328-43ca4bdd2202@googlegroups.com>...
>
>
> for z = 1 : 21
>
>  A = [-PV_supply -WT_supply -Diesel_supply(z)];
>
>    f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  % how do we manipulate diesel cost?
>
>  b = -Demand;
>
>  [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
>
>
> end
>
> what I have tried above so far gives me an inconsistent matrix size since I think it is not looping correctly
=====================

Probably because in this expression

A = [-PV_supply -WT_supply -Diesel_supply(z)]

you are concatenating 2 vectors with the scalar Diesel_supply(z)
```
 0
Reply mattjacREMOVE (3190) 7/11/2012 7:59:13 PM

```On Wednesday, 11 July 2012 20:59:13 UTC+1, Matt J   wrote:
> &gt;
> &gt;
> &gt; for z = 1 : 21
> &gt;
> &gt;  A = [-PV_supply -WT_supply -Diesel_supply(z)];
> &gt;
> &gt;    f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  % how do we manipulate diesel cost?
> &gt;
> &gt;  b = -Demand;
> &gt;
> &gt;  [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
> &gt;
> &gt;
> &gt; end
> &gt;
> &gt; what I have tried above so far gives me an inconsistent matrix size since I think it is not looping correctly
> =====================
>
>
> Probably because in this expression
>
> A = [-PV_supply -WT_supply -Diesel_supply(z)]
>
> you are concatenating 2 vectors with the scalar Diesel_supply(z)

for z = 1:21
A= [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];

f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  ;

b = -Demand;

[x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)

end

However, this of course only gives the "Diesel_supply" value for z = 21.
I need to index the LHS of the A equation, do you know how this is done?
Thank you
```
 0

```On Wednesday, 11 July 2012 21:04:47 UTC+1, Andrew Alkiviades  wrote:
> On Wednesday, 11 July 2012 20:59:13 UTC+1, Matt J   wrote:
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; for z = 1 : 21
> &gt; &amp;gt;
> &gt; &amp;gt;  A = [-PV_supply -WT_supply -Diesel_supply(z)];
> &gt; &amp;gt;
> &gt; &amp;gt;    f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  % how do we manipulate diesel cost?
> &gt; &amp;gt;
> &gt; &amp;gt;  b = -Demand;
> &gt; &amp;gt;
> &gt; &amp;gt;  [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; end
> &gt; &amp;gt;
> &gt; &amp;gt; what I have tried above so far gives me an inconsistent matrix size since I think it is not looping correctly
> &gt; =====================
> &gt;
> &gt;
> &gt; Probably because in this expression
> &gt;
> &gt; A = [-PV_supply -WT_supply -Diesel_supply(z)]
> &gt;
> &gt; you are concatenating 2 vectors with the scalar Diesel_supply(z)
>
> Indeed I have adjusted to
>  for z = 1:21
>  A= [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];
>
>    f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  ;
>
>
>  b = -Demand;
>
>  [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
>
>  end
>
> However, this of course only gives the &quot;Diesel_supply&quot; value for z = 21.
> I need to index the LHS of the A equation, do you know how this is done?
> Thank you

This format

A(:,:,z) = [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];

only gives to z = 2 - Is this because it attempts to code in a 3 dimensional format?
```
 0

```Andrew Alkiviades <andrew.alkiviades@gmail.com> wrote in message <81a8715a-2635-414b-953d-d51d67898ff3@googlegroups.com>...
>
> This format
>
>
>  A(:,:,z) = [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];
>
> only gives to z = 2 - Is this because it attempts to code in a 3 dimensional format?

Hmmm. I don't see why this line of code would give you an error for any z>=1...
```
 0
Reply mattjacREMOVE (3190) 7/11/2012 8:32:12 PM

```The optimisation works with

Diesel_supply = Diesel_matrix(:,1); % Power output of diesel generator

hourly_cost = Diesel_matrix(:,2);  % Diesel cost of running genreator at that output

for z = 1:size(Diesel_matrix,1)

A = [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];

f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  ;

b = -Demand;

[x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)

end

However, the matrix A only includes Diesel_supply values of 200, which is the last value of the predetermined matrix
```
 0

```On Wednesday, 11 July 2012 21:34:40 UTC+1, Andrew Alkiviades  wrote:
> The optimisation works with
>
>
>
> Diesel_supply = Diesel_matrix(:,1); % Power output of diesel generator
>
> hourly_cost = Diesel_matrix(:,2);  % Diesel cost of running genreator at that output
>
>
>
>  for z = 1:size(Diesel_matrix,1)
>
>  A = [-PV_supply -WT_supply ones(24,1).*-Diesel_supply(z)];
>
>    f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(z))]  ;
>
>
>  b = -Demand;
>
>  [x,fval,exitflag] = linprog(f,A,b,[],[],lb,ub)
>
>  end
>
> However, the matrix A only includes Diesel_supply values of 200, which is the last value of the predetermined matrix

With the code in me previous post - I can run the optimisation for 21 sets of x's (which is equal to the number of loops I am trying to do)
therefore what remains is to make sure that for each row in A for the diesel_supply column, the cell is going from z = 1 to 21

also, in the "f" vector

f = [CRF_PV*CC_PV; CRF_WT*CC_WT; (CRF_Diesel_generator*CC_Diesel)+sum(hourly_cost(1:z))]  ;

I am trying to code so that in row 3, the +sum(hourly_cost(1:z)) component is not multiplied by x3, i.e is not considered a coefficient of x3, but is added onto CRF_Diesel_generator*CC_Diesel * x3
```
 0

35 Replies
37 Views

Similiar Articles:

7/7/2012 9:02:41 PM