locked
GateTransform failed with 3 error(s): 'logisticEffect0' is not defined in all cases. It is only defined for (vbool0=true)(vbool1=false) RRS feed

  • Question

  • Hi

    I'm trying to implement a conditional branch in my model. There is a sum value, which I have to decide the value of another variable based on it. I want to use this sum variable, in this form:

    if(sum>0) then the value of the second variable should be one.

    ifNot(sum>0) then the value of the second variable should be zero.

    Now, when I run it, I get an error:

    GateTransform failed with 3 error(s) and 0 warning(s):
    Error 0: 'logisticEffect0' is not defined in all cases.  It is only defined for (vbool0=true)(vbool1=false) in
    { .............

    for (int layer = 0; layer < NumLayers.ObservedValue - 1; layer++)
                {
                    using (ForEachBlock firstBlock = Variable.ForEach(geneRange))
                    {
                        Variable<double> selfEffect = (-(alpha[geneRange] * timeSeriesData[layer][geneRange])).Named("selfEffect_" + layer);
                        VariableArray<double> weightSumArray = Variable.Array<double>(geneWeightRange).Named("weightSum_" + layer);
                        genesubarray = Variable.Subarray(timeSeriesData[layer], indicesArray[geneRange]).Named("genesubarray_" + layer);
                        weightSumArray[geneWeightRange] = (w[geneRange][geneWeightRange] * genesubarray[geneWeightRange]).Named("weightSumArray_" + layer);
                        perturbEffectSubarray = Variable.Subarray(pertData, pertIndices[geneRange]).Named("perturbEffectSubarray_" + layer);
                        VariableArray<double> perturbationEffect = Variable.Array<double>(perturbRange).Named("perturbationEffect_" + layer);
                        perturbationEffect[perturbRange] = genePertW[geneRange][perturbRange] * perturbEffectSubarray[perturbRange];
                        Variable<double> totalSum = (Variable.Sum(perturbationEffect).Named("sum_perturbationEffect_" + layer) + Variable.Sum(weightSumArray).Named("sum_weightSumArray_" + layer)).Named("totalSum_" + layer); 
                        Variable<double> logisticEffect = Variable.New<double>().Named("logisticEffect" + layer);
                        using (Variable.If(totalSum > 0)) { logisticEffect.SetTo(Variable.Constant(1.0)); }
                        using (Variable.IfNot(totalSum > 0)) logisticEffect.SetTo(Variable.Constant(0.0));
                        Variable<double> othersEffect = beta[geneRange] * (logisticEffect);
    
                        timeSeriesData[layer + 1][geneRange] = (othersEffect - selfEffect).Named("timeSeriesData_" + layer);
                    }
                }

    Can anybody please help me in understanding why this happens?

    This if / ifNot makes two branch comming out of totalSum variable in model diagram. one is named vbool0 and the other vbool1.

    Why two bool variables? I was trying to do something like this example. But it doesn't work for my case. Even if I write simple branch like the example, instead of creating totalSum variable, the models compilation fails.

    Thanks a lot in advance.


    • Edited by RazinR Friday, August 8, 2014 11:34 PM
    Friday, August 8, 2014 11:32 PM

Answers

  • Try putting (totalSum>0) into a variable and branching on that variable.
    • Marked as answer by RazinR Sunday, August 10, 2014 10:09 AM
    Saturday, August 9, 2014 8:12 AM
    Owner