changing number to string

I need to change a computed (or looked-up) number into a string, so
that I can use it as an index. For instance, consider the setup as
follows:

Sets
i buses / 14 /
n transmission (TX) lines / 1
3 /
m bus parameters / VMin, VMax /
p TX parameters / R, X, B, StartBus, EndBus, Imax /
q calc TX parameter type / B, G, Yshunt /

Table TXParam(n,p)
R X B StartBus
EndBus Imax
1 0.005 0.005 1.2 1
2 7
2 0.005 0.005 1.2 1
3 7
3 0.005 0.005 1.2 2
3 7;

Table BusParam(i,m)
VMin VMax
1 0.85 1.05
2 0.90 1.05
3 0.95 1.05
4 1.00 1.05

Table CalcTXParams(n,q)
G B Yshunt
1 0 0 0
2 0 0 0
3 0 0 0;

Now assume that I want to calculate the Yshunt values in the
CalcTXParams(n,q) table with a statement that would do the following:

CalcTXParams(n,“Yshunt”) = BusParam(n+1,“VMin”);

This won’t work, because n+1 is not a string. Is there a function or
other way to convert it to a string?

Thanks,
Tom



\

Tom,

Let me suggest another way around.
First, my advice is to avoid using pure numeric labels for set
elements. In your example below, I would rather write

set
i buses / i1 * i4 /
n transmission lines / n1 * n3 /

;

Second, it is probably better to define some kind of “incidence
matrix” between your buses and lines.
So for instance, in your simple network above, link the “oriented”
transmission link to buses using :

table inc_mat (n,i)

i1 i2 i3 i4
n1 -1 +1 0 0
n2 0 -1 +1 0
n3 0 0 -1 +1
;

then, if you want to compute a specific value for a given line, which
depends on some characterstics of the end bus of the line, like in
your example below, you could write:

CalcTXParams(n,“Yshunt”) = sum(i $(inc_mat(n,i) eq +1), BusParam
(i,“VMin”));

and this is it – whether your set labels are purely numeric or not.
Respectively, when it depends on the starting bus of the line, use the
conditional expression: $(inc_mat(n,i) eq -1)

Further, you might want to use a slightly more compact notation,
defining the dynamic sets:

set start_bus(n,i), end_bus(n,i) ;
start_bus(n,i) (inc_mat(n,i) eq -1) = yes ; end_bus(n,i) (inc_mat(n,i) eq +1) = yes ;

then your conditional assignement becomes:

CalcTXParams(n,“Yshunt”) = sum(i $end_bus(n,i), BusParam
(i,“VMin”));

Hope this helps
cheers
dax

On Jan 6, 10:33 pm, tom smith wrote:

I need to change a computed (or looked-up) number into a string, so
that I can use it as an index. For instance, consider the setup as
follows:

Sets
i buses / 14 /
n transmission (TX) lines / 1
3 /
m bus parameters / VMin, VMax /
p TX parameters / R, X, B, StartBus, EndBus, Imax /
q calc TX parameter type / B, G, Yshunt /

Table TXParam(n,p)
R X B StartBus
EndBus Imax
1 0.005 0.005 1.2 1
2 7
2 0.005 0.005 1.2 1
3 7
3 0.005 0.005 1.2 2
3 7;

Table BusParam(i,m)
VMin VMax
1 0.85 1.05
2 0.90 1.05
3 0.95 1.05
4 1.00 1.05

Table CalcTXParams(n,q)
G B Yshunt
1 0 0 0
2 0 0 0
3 0 0 0;

Now assume that I want to calculate the Yshunt values in the
CalcTXParams(n,q) table with a statement that would do the following:

CalcTXParams(n,“Yshunt”) = BusParam(n+1,“VMin”);

This won’t work, because n+1 is not a string. Is there a function or
other way to convert it to a string?

Thanks,
Tom


\