discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] ValueError: The truth value of an array with more tha


From: Luis Felipe Albarracin Sanchez
Subject: [Discuss-gnuradio] ValueError: The truth value of an array with more than one element is ambiguous - in OOT
Date: Tue, 19 Jun 2018 21:10:21 +0200

Hello all,

I am developing a Fuzzy system to control some variables in a Communicatiosn system,  and i have the following code:

import numpy as np
import string
import pmt
import struct
import pylab as pl
from gnuradio import gr
from gnuradio import digital

# Variable Global

lim=99
x =pl.linspace(0, 100, lim)#Output universe

#Parameters for membership functions
#Input
mp1=[25, 75 ]#Mean
dp1=[25, 25]#Standar Deviation
#Output
mpy=[25, 75]
dpy=[15, 15]

class mod_fuzzy_t1_selector(gr.sync_block):
    """
    docstring for block mod_fuzzy_t1_selector
    """
    def __init__(self):
        #Internal Variables Parameters
        self.d_BLER=np.float32(0)
        self.d_Act_Nod=np.float32(0)


        gr.sync_block.__init__(self,
            name="mod_fuzzy_t1_selector",
            in_sig=[np.float32, np.float32],
            out_sig=[np.float32, np.float32])

    def Normaliza(self):
               
        self.xpa1 = (self.d_BLER*100)/30

        if self.d_Act_Nod[0] == 0:
           self.xpa2 = 25
        else:
           self.xpa2 = 75
def Fuzzy(self):

        xp1=self.xpa1
            xp2=self.xpa2
       
        u11=pl.exp((-0.5*(xp1-mp1[0])**2)/((dp1[0])**2))
        u12=pl.exp((-0.5*(xp1-mp1[1])**2)/((dp1[1])**2))

       
        u21=pl.exp((-0.5*(xp2-mp1[0])**2)/((dp1[0])**2))
        u22=pl.exp((-0.5*(xp2-mp1[1])**2)/((dp1[1])**2))

  
        y11=pl.exp((-0.5*(x-mpy[0])**2)/((dpy[0])**2))
        y12=pl.exp((-0.5*(x-mpy[1])**2)/((dpy[1])**2))

      
        y21=pl.exp((-0.5*(x-mpy[0])**2)/((dpy[0])**2))
        y22=pl.exp((-0.5*(x-mpy[1])**2)/((dpy[1])**2))

   
        A1 = [u12, u22]
        Ar1 = min (A1)
         .
         .
         .
         .
def work(self, input_items, output_items):
    BLERv = input_items[0]
    BLER=BLERv
        Act_Nodv = input_items[1]
    Act_Nod=Act_Nodv
        self.d_Act_Nod=np.float32(Act_Nod)
    self.d_BLER=np.float32(BLER)
    out0 = output_items[0]
    out1 = output_items[1]
    self.Normaliza()
    out_global = self.Fuzzy()
    out0[0] = out_global[0]
    out1[0] = out_global[1]

        return len(input_items[0])

I compile it without issues, but when i run the flowgrapgh it shows the following error with the block i just came up with:

Executing: /usr/bin/python2 -u /home/luisfelipe/Documentos/GNU Tests/top_block.py

handler caught exception: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/gateway.py", line 55, in eval
    try: self._callback()
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/gateway.py", line 160, in __gr_block_handle
    ) for i in self.__out_indexes],
  File "/usr/local/lib/python2.7/dist-packages/ieee802_11/mod_fuzzy_t1_selector.py", line 151, in work
    out_global = self.Fuzzy()
  File "/usr/local/lib/python2.7/dist-packages/ieee802_11/mod_fuzzy_t1_selector.py", line 97, in Fuzzy
    Ar1 = min (A1)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
thread[thread-per-block[2]: <block mod_fuzzy_t1_selector (19)>]: SWIG director method error. Error detected when calling 'feval_ll.eval'

I would appreciate if someone could give me a ligth of what should i change in the code so i can fix this. I don know why it says that is an array when i am putting a variable (float). Any othe ideas regarding the problem are welcome.

Kind regards.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]