# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda root]
#     language: python
#     name: conda-root-py
# ---

# +
# #!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt 
import math

def fun(TComfAgent):
    C = 0
    T = 24
    diffAux = T - TComfAgent
    if diffAux < 0:
        T = TComfAgent - diffAux
    diff = math.fabs(T - TComfAgent)
    if(2>=diff):
        C = 100-10*math.pow((T-TComfAgent)/1.5, 2)
    elif(diff>2 and 4>=diff):
        m = -(82-50)/(4-2)
        x0 = (TComfAgent+2)-(82/m)
        C = m*(T-x0)
    else:
        x0 = math.log(50) + (TComfAgent+4)
        C = math.pow(math.e, x0-T)
        C = float(int(C))
    return C


vfun = np.vectorize(fun)

x = np.linspace(18, 30, 1000) 
y = vfun(x)
plt.plot(x, y, '-')
plt.xlabel('Temperature')
plt.ylabel('Comfort [%]')
plt.show()

# -





StarcoderdataJupyterScriptsDedupFiltered