How to use the gekko.gk_operators.GK_Operators function in gekko

To help you get started, we’ve selected a few gekko examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BYU-PRISM / GEKKO / gekko / gekko.py View on Github external
def atanh(self,other):
        return GK_Operators('atanh('+str(other) + ')')
    def cos(self,other):
github BYU-PRISM / GEKKO / gekko / gekko.py View on Github external
def Const(self, value=0, name=None):
        """ Define a constant. There is no functional difference between using
        this Const, a python variable or a magic number. However, this Const
        can be provided a name to make the .apm model more clear."""
        if name is not None:
            name = re.sub(r'\W+', '_', name).lower()
            if name == '':
                name = None
        if isinstance(value, (list,np.ndarray)):
            raise ValueError("Constant value must be scalar.")
        const = GK_Operators(name,value)
        self._constants.append(const)
        return const
github BYU-PRISM / GEKKO / gekko / gk_operators.py View on Github external
def __eq__(self,other): #equal ==
        return GK_Operators(str(self) + '=' + str(other))
    #math operators
github BYU-PRISM / GEKKO / gekko / gk_operators.py View on Github external
def __abs__(self):
        return GK_Operators('abs('+str(self)+')')
    """
github BYU-PRISM / GEKKO / gekko / gk_parameter.py View on Github external
FV_inout_options = Param_inout_options+[]
FV_output_options = Param_output_options+['LSTVAL', 'NEWVAL']

MV_inout_options = FV_inout_options+[]
MV_input_options = FV_input_options + ['COST', 'DCOST', 'MV_STEP_HOR','REQONCTRL', 'TIER']
MV_output_options = FV_output_options + ['AWS', 'DPRED', 'NXTVAL', 'PRED', ]

#gather in dictionary
parameter_options = {'FV':{'inputs':FV_input_options, 'outputs':FV_output_options, 'inout': FV_inout_options}, 
                     'MV':{'inputs':MV_input_options,'outputs':MV_output_options,'inout':MV_inout_options},
                     None:{'inputs':Param_input_options,'outputs':Param_output_options,'inout':Param_inout_options}}

"""
from .properties import parameter_options as options

class GKParameter(GK_Operators):
    """Represents a parameter in a model."""
    counter = 1

    def __init__(self, name='', value=None, integer=False):
        if name == '':
            name = 'p' + GKParameter.counter
            GKParameter.counter += 1
            if integer == True:
                name = 'int_' + name
                
        # prevents the __setattr__ function from sending options to the server
        # until the __init__ function has completed since they should only be
        # sent if changed from their defaults
        self.__dict__['_initialized'] = False
        
        GK_Operators.__init__(self, name, value=value)
github BYU-PRISM / GEKKO / gekko / gekko.py View on Github external
def exp(self,other):
        return GK_Operators('exp(' + str(other) + ')')
    def log(self,other):
github BYU-PRISM / GEKKO / gekko / gekko.py View on Github external
def get_names(self):
        """ Matches names of constants, parameters, intermediates and variables
        to the python name from scope __main__. Name is converted to lowercase.
        The function cannot be used after a variable is used (including in 
        defining intermediate equations). USE WITH CAUTION. """
        import __main__ as main
        main_dict = vars(main)
        for var in main_dict:
            if isinstance(main_dict[var], GK_Operators):
                main_dict[var].__dict__['name'] = re.sub(r'\W+', '_', var).lower()
                print('Found ' + var)
            if isinstance(main_dict[var], list):
                list_var = main_dict[var]
                for i in range(len(list_var)):
                    if isinstance(list_var[i], GK_Operators):
                        list_var[i].__dict__['name'] = re.sub(r'\W+', '_', var).lower()+'['+str(i)+']'
                        print('Found ' + var+'['+str(i)+']')
github BYU-PRISM / GEKKO / gekko / gk_operators.py View on Github external
def __div__(self,other): # /
        return GK_Operators('((' + str(self) + ')/(' + str(other) + '))')
    def __truediv__(self,other): # /
github BYU-PRISM / GEKKO / gekko / gekko.py View on Github external
def atan(self,other):
        return GK_Operators('atan('+str(other) + ')')
    def atanh(self,other):