I am not able to sort out the Error 148 in GAMS Studio 39.3 for my problem.
148 Dimension different - The symbol is referenced with more/less indices as declared
following is the details:
Sets
EV 'EV unit'/ev1*ev1/
Asev1 'set ev index for values of sch' /1*2/
taev 'set of arrival'/taev1*taev1/
tdev 'set of departure'/tdev1*tdev1/
t ’time periods’ /t1*t2/
w ’scenarios’ /w1*w2/;
SCALAR
Pev ’EV power traded in the Energy market’/7.8/;
PARAMETER
Asev 'alphasch(ev) values of alphasch'
/1 0
2 1/;
PARAMETER
weigth(w) ’weight of scenarios’
/w1 0.05
w2 0.05/;
POSITIVE VARIABLES
As(ev,t,w) 'EV scheduling in time period t';
EQUATION
Pev1 'power output of EV'
Pev1(t,w).. Pev=e=sum(ev,Pev(ev,t,w)*Asev('ev,t,w'));
I am not sure where i am making mistake however i am getting Error 148.
Error 148 Dimension different - The symbol is referenced with more/less
**** indices as declared
Note: I got $148 error under w)*
Pev1(t,w).. Pev=e=sum(ev,Pev(ev,t,w)*Asev('ev,t,w'));
First, you probably don't want the quotes at the end, which makes ev,t,w one specific element. So, you should change it to this:
Pev1(t,w).. Pev=e=sum(ev,Pev(ev,t,w)*Asev(ev,t,w));
But still, this does not work. You defined Asev as 1-dimensional parameter with the elements 1 and 2 above. That does not fit your usage here. So, what do you actually intend? Either the definition of Asev must be wrong or your usage. Or did you actually want to use As here instead, like this?
Pev1(t,w).. Pev=e=sum(ev,Pev(ev,t,w)*As(ev,t,w));
This would resolve the problem for the last term, but give an error before, since also the use of Pev (with 3 indices here) does not match your definition as Scalar above.
Thanks for your feedback!
As or Asev is just the declaration.
Firstly, I removed the quotes at the end, which makes (ev,t,w)
and here it is
Pev1(t,w).. Pev=e=sum(ev,Pev(ev,t,w)*As(ev,t,w));
The problem for the last term is still existing.
I didn't get it you saying " the use of Pev (with 3 indices here) does not match your definition as Scalar above."
I think the Pev (with 3 indices here) match with the scalar above
hi I'm trying to finish a crystal report, summary report, but I'm getting division by zero error. I've looked up everything and none of the options have helped me. The options already out there have only made my math formula turn everything to a zero.
if 1-({#dspStkWip}+{tblItem.OnOrderQuantity}/{#dspNeed})*100 > .15
then crYellow
else CrNocolor;
So whats happening since the need has zeros in the column it will end up making everything 0. I just need to find a way to implement a check for zero and to see if it needs to be highlighted in the column.
The {#dspNeed} field looks like the culprit to me. If this field contains 0 or NULL values then you would get the division by zero error you described.
Try this:
IF {#dspNeed} <> 0 THEN
if 1-({#dspStkWip}+{tblItem.OnOrderQuantity}/{#dspNeed})*100 > .15
then crYellow
else CrNocolor
ELSE
\\ code for how to handle values that throw division by zero error goes here
The following code is showing result as Nan% if values are zero:
=FORMAT(((Sum(IIF(Fields!flag.Value=1,CINT(Fields!area1.Value),0)))
/ (Sum(IIF(Fields!flag.Value=1,CINT(Fields!UnitArea.Value),0))) *100),"N") + "%"
The simplest way to avoid the divide by zero error here is to not create it in the first place! If you replace the 0 as second return value in the divisor Iif expression with a 1, then the problem goes away.
That said I think your whole expression could do with simplifying somewhat. If I read it correctly you want to determine the proportion of area1 within UnitArea but only when the value of flag is 1. The expression could be thus written:
=Format(
Iif(
Fields!flag.Value = 1,
CInt(Fields!area1.Value) / CInt(Fields!UnitArea.Value),
Nothing
),
"Percent"
)
Note that I've dropped the multiplier and instead used the Format function to return the result of the division as a percentage (you could also simply further by removing the Format function entirely and handling the formatting in the designer).
You don't have to layout the expression with indentation as I have, but the expression builder ignores the whitespace and it does make larger expressions easier to read, so I think its a good habit to get into.
I'm having problems with dividing two float values that appears to be a simple process.
http://imgur.com/EZz5Q1Z
the floats l and larg have the values of 20 and 10, which should result in a n1 value of 2. That's not the case though.
Thanks in advance.
You put your breakpoint on the line containing the division, which means the debugger is showing the value of the variable before the division takes place. Step to the next instruction to see the correct value.
I am writing a report in SQL Server 2005 Reporting Services, involving the division of money values that might be equal to zero. I put the following code in to check for a zero denominator:
=IIf(Sum(Fields!PreviousPremiumMTD.Value) = 0, "N/A", FormatPercent((Sum(Fields!PremiumMTD.Value) / Sum(Fields!PreviousPremiumMTD.Value))-1, 0))
However, for some reason I am still getting #Error displaying on my report with the following warning thrown:
[rsRuntimeErrorInExpression] The Value expression for the textbox ‘textbox62’ contains an error: Attempted to divide by zero.
Any assistance is greatly appreciated.
IIF evaluates the expression before passing that to function, thats why you will always get the DivideByZero error here.
See an example post: http://secretgeek.net/iif_function.asp