Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last): File "<ipython-input-73-8928f248afed>", line 23, in my_function AttributeError: 'float' object has no attribute 'apply' Exception ignored on calling ctypes callback function: <function my_function="" at="" 0x000001dc00155d30="">

My code is as follows: api = EnergyPlusAPI()

Loading the ANN model using pickle function. pick

with open('ANNClassify.pickle', 'rb') as f: ANNclassify = pickle.load(f)

def my_function(state):

if api.exchange.api_data_fully_ready(state): #Necessary condition

    if api.exchange.warmup_flag(state) == 0:

        To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
        Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
        # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

        To = api.exchange.get_variable_value(state, To_handle)
        Ti = api.exchange.get_variable_value(state, Ti_handle)

        To = To.apply(stats.zscore)
        Ti = Ti.apply(stats.zscore)

        var_list = [Ti, To]
        var_list = torch.FloatTensor(var_list)
        var_list = var_list.reshape(1,2)

        Modified_Sch = ANNclassify(var_list)

        Modified_Sch_1 = Modified_Sch.item()

        if Modified_Sch_1 <= 0:

            Modified_Sch_1 = 0

        else:

            Modified_Sch_1 = 1

        sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

        self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition api.state_manager.reset_state(state) api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function) api.runtime.run_energyplus(state, [ '-d', '/Users/.../Desktop/ReOrg/EPlus_Files', '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw', 'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf' ] )

Is there any way I can solve this issue? Thanks..

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last): File "<ipython-input-73-8928f248afed>", line 23, in my_function AttributeError: 'float' object has no attribute 'apply' Exception ignored on calling ctypes callback function: <function my_function="" at="" 0x000001dc00155d30="">

My code is as follows: api = EnergyPlusAPI()

Loading the ANN model using pickle function. pick

with open('ANNClassify.pickle', 'rb') as f: ANNclassify = pickle.load(f)

def my_function(state):

if api.exchange.api_data_fully_ready(state): #Necessary condition

    if api.exchange.warmup_flag(state) == 0:

        To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
        Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
        # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

        To = api.exchange.get_variable_value(state, To_handle)
        Ti = api.exchange.get_variable_value(state, Ti_handle)

        To = To.apply(stats.zscore)
        Ti = Ti.apply(stats.zscore)

        var_list = [Ti, To]
        var_list = torch.FloatTensor(var_list)
        var_list = var_list.reshape(1,2)

        Modified_Sch = ANNclassify(var_list)

        Modified_Sch_1 = Modified_Sch.item()

        if Modified_Sch_1 <= 0:

            Modified_Sch_1 = 0

        else:

            Modified_Sch_1 = 1

        sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

        self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition api.state_manager.reset_state(state) condition

api.state_manager.reset_state(state)

api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function) my_function)

api.runtime.run_energyplus(state, [ '-d', '/Users/.../Desktop/ReOrg/EPlus_Files', '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw', 'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf' ] )

Is there any way I can solve this issue? Thanks..

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last): File "<ipython-input-73-8928f248afed>", line 23, in my_function AttributeError: 'float' object has no attribute 'apply' Exception ignored on calling ctypes callback function: <function my_function="" at="" 0x000001dc00155d30="">

My code is as follows: follows:

api = EnergyPlusAPI()

EnergyPlusAPI() # Loading the ANN model using pickle function. pick

pick with open('ANNClassify.pickle', 'rb') as f: ANNclassify = pickle.load(f)

pickle.load(f) def my_function(state):

my_function(state):
    if api.exchange.api_data_fully_ready(state): #Necessary condition
      if api.exchange.warmup_flag(state) == 0:
          To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
         Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
         # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

         To = api.exchange.get_variable_value(state, To_handle)
         Ti = api.exchange.get_variable_value(state, Ti_handle)

         To = To.apply(stats.zscore)
         Ti = Ti.apply(stats.zscore)

         var_list = [Ti, To]
         var_list = torch.FloatTensor(var_list)
         var_list = var_list.reshape(1,2)

         Modified_Sch = ANNclassify(var_list)

         Modified_Sch_1 = Modified_Sch.item()

         if Modified_Sch_1 <= 0:

0:       
                Modified_Sch_1 = 0

        else:

0       
            else:              
                Modified_Sch_1 = 1

         sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

         self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition
api.state_manager.reset_state(state)
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)

api.runtime.run_energyplus(state,
    [
        '-d', '/Users/.../Desktop/ReOrg/EPlus_Files',
        '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw',
        'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf'
    ]
)

state = api.state_manager.new_state() #Necessary condition

api.state_manager.reset_state(state)

api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)

api.runtime.run_energyplus(state, [ '-d', '/Users/.../Desktop/ReOrg/EPlus_Files', '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw', 'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf' ] )

Is there any way I can solve this issue? Thanks..

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last):
  File "<ipython-input-73-8928f248afed>", line 23, in my_function
AttributeError: 'float' object has no attribute 'apply'
Exception ignored on calling ctypes callback function: <function my_function="" at="" 0x000001dc00155d30="">

my_function at 0x000001DC00155D30>

My code is as follows:

api = EnergyPlusAPI()

# Loading the ANN model using pickle function. pick

with open('ANNClassify.pickle', 'rb') as f:
    ANNclassify = pickle.load(f)        

def my_function(state):
    if api.exchange.api_data_fully_ready(state): #Necessary condition
        if api.exchange.warmup_flag(state) == 0:
            To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
            Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
            # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

            To = api.exchange.get_variable_value(state, To_handle)
            Ti = api.exchange.get_variable_value(state, Ti_handle)

            To = To.apply(stats.zscore)
            Ti = Ti.apply(stats.zscore)

            var_list = [Ti, To]
            var_list = torch.FloatTensor(var_list)
            var_list = var_list.reshape(1,2)

            Modified_Sch = ANNclassify(var_list)

            Modified_Sch_1 = Modified_Sch.item()

            if Modified_Sch_1 <= 0:       
                Modified_Sch_1 = 0       
            else:              
                Modified_Sch_1 = 1

            sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

            self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition
api.state_manager.reset_state(state)
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)

api.runtime.run_energyplus(state,
    [
        '-d', '/Users/.../Desktop/ReOrg/EPlus_Files',
        '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw',
        'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf'
    ]
)

Is there any way I can solve this issue? Thanks..

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last):
  File "<ipython-input-73-8928f248afed>", line 23, in my_function
AttributeError: 'float' object has no attribute 'apply'
Exception ignored on calling ctypes callback function: <function my_function at 0x000001DC00155D30>

My code is as follows:

api = EnergyPlusAPI()

# Loading the ANN model using pickle function. pick

with open('ANNClassify.pickle', 'rb') as f:
    ANNclassify = pickle.load(f)        

def my_function(state):
    if api.exchange.api_data_fully_ready(state): #Necessary condition
        if api.exchange.warmup_flag(state) == 0:
            To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
            Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
            # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

            To = api.exchange.get_variable_value(state, To_handle)
            Ti = api.exchange.get_variable_value(state, Ti_handle)

            To = To.apply(stats.zscore)
            Ti = Ti.apply(stats.zscore)

            var_list = [Ti, To]
            var_list = torch.FloatTensor(var_list)
            var_list = var_list.reshape(1,2)

            Modified_Sch = ANNclassify(var_list)

            Modified_Sch_1 = Modified_Sch.item()

            if Modified_Sch_1 <= 0:       
                Modified_Sch_1 = 0       
            else:              
                Modified_Sch_1 = 1

            sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

            self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition
api.state_manager.reset_state(state)
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)

api.runtime.run_energyplus(state,
    [
        '-d', '/Users/.../Desktop/ReOrg/EPlus_Files',
        '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw',
        'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf'
    ]
)

Is there any way I can solve this issue? Thanks..

Error: 'float' object has no attribute 'apply'

Hi...

I am trying to use ANN model to predict the window opening and closing. For this I have used sensor data to get indoor and outdoor temperature. I have also trained and imported by ANN model using pickle library. The ANN model is named as 'ANNclassify'. The value from the ANNclassify will be given to actuator, which will change my schedule.

For some reason, the code is giving me the following error.

Traceback (most recent call last):
  File "<ipython-input-73-8928f248afed>", line 23, in my_function
AttributeError: 'float' object has no attribute 'apply'
Exception ignored on calling ctypes callback function: <function my_function at 0x000001DC00155D30>

My code is as follows:

api = EnergyPlusAPI()

# Loading the ANN model using pickle function. pick

with open('ANNClassify.pickle', 'rb') as f:
    ANNclassify = pickle.load(f)        

def my_function(state):
    if api.exchange.api_data_fully_ready(state): #Necessary condition
        if api.exchange.warmup_flag(state) == 0:
            To_handle = api.exchange.get_variable_handle(state, "Site Outdoor Air Drybulb Temperature", "Environment")
            Ti_handle = api.exchange.get_variable_handle(state, "Zone Mean Air Temperature", "SecondFloor:Unit1XBR")
            # "Zone Thermostat Cooling Setpoint Temperature", zone_name)

            To = api.exchange.get_variable_value(state, To_handle)
            Ti = api.exchange.get_variable_value(state, Ti_handle)

            To = To.apply(stats.zscore)
            Ti = Ti.apply(stats.zscore)

            var_list = [Ti, To]
            var_list = torch.FloatTensor(var_list)
            var_list = var_list.reshape(1,2)

            Modified_Sch = ANNclassify(var_list)

            Modified_Sch_1 = Modified_Sch.item()

            if Modified_Sch_1 <= 0:       
                Modified_Sch_1 = 0       
            else:              
                Modified_Sch_1 = 1

            sch_handle = self.api.exchange.get_actuator_handle(state,
                                                           "SCHEDULE:COMPACT",
                                                           "SCHEDULE VALUE",
                                                           "LIV1XWIN_SCH")

            self.api.exchange.set_actuator_value(state, sch_handle, Modified_Sch_1)

state = api.state_manager.new_state() #Necessary condition
api.state_manager.reset_state(state)
api.runtime.callback_begin_zone_timestep_after_init_heat_balance(state, my_function)

api.runtime.run_energyplus(state,
    [
        '-d', '/Users/.../Desktop/ReOrg/EPlus_Files',
        '-w', '/Users/.../Desktop/ReOrg/EPlus_Files/Weather_File_SYR.epw',
        'C:/Users/.../Desktop/ReOrg/EPlus_Files/Heating_design_new.idf'
    ]
)

Is there any way I can solve this issue? Thanks..