How to use the gekko.gk_parameter.GK_FV 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 FV(self, value=None, lb=None, ub=None, integer=False, fixed_initial=True, name=None):
        """A manipulated variable that is fixed with time. Therefore it lacks
        time-based attributes."""
        if name is not None:
            name = re.sub(r'\W+', '_', name).lower()
        else:
            name = 'p' + str(len(self._parameters) + 1)
        if integer == True:
            name = 'int_'+name

        parameter = GK_FV(name=name, value=value, lb=lb, ub=ub, gk_model=self._model_name, model_path=self._path, integer=integer)
        self._parameters.append(parameter)
        if fixed_initial is False:
            self.Connection(parameter,'calculated',pos1=1,node1=1)
        return parameter
github BYU-PRISM / GEKKO / gekko / gk_gui.py View on Github external
"""Special handling for GK_Parameters"""
        main_dict = vars(main)
        data = list(filter(lambda d: d['name'] == param, self.gekko_data['vars']['parameters']))[0]
        try:
            data['data'] = self.results[main_dict[param].name]
            data['x'] = self.results['time']
            data['options'] = self.options[main_dict[param].name]
        except KeyError:
            # Some vars are not in options.json and so do not make it into self.options
            # This case should be safe to ignore
            pass
        except Exception:
            print("Error getting data for: %s (%s)" % (param, main_dict[param].name))

        ## historical data
        if isinstance(main_dict[param], (GK_MV, GK_FV)):
            data_hist = list(filter(lambda d: d['name'] == param + '_hist', self.gekko_data['vars']['parameters']))[0]
            data_hist['data'] = data_hist['data'] + [self.results[main_dict[param].name][0]]
            timestep = self.results['time'][1] - self.results['time'][0]
            data_hist['x'] = [data_hist['x'][0] - timestep] + data_hist['x']
github BYU-PRISM / GEKKO / gekko / gk_parameter.py View on Github external
self.COST = None
        self.DCOST = None
        self.DPRED = None
        self.MV_STEP_HOR = None
        self.NXTVAL = None
        self.PRED = None
        self.REQONCTRL = None
        self.TIER = None

        #register fixed values through connections to ensure consistency in the 
        #csv file, otherwise the requested fixed value will be overridden by
        #whatever initialization value is in the csv
        self._override_csv = []
        
        
        GK_FV.__init__(self, name=name, value=value, lb=lb, ub=ub, gk_model=gk_model, model_path=model_path, integer=integer)
github BYU-PRISM / GEKKO / gekko / gk_parameter.py View on Github external
#close file
        f.close()
        
        #write tag file
        f = open(os.path.join(self.path,self.name),'w')
        #write measurement
        f.write(str(measurement))
        #close tag file
        f.close()
        
        
        



class GK_MV(GK_FV):
    """ Manipulated Variable. Inherits GK_FV."""

    def __init__(self, name='', value=0, lb=None, ub=None, gk_model=None, model_path=None, integer=False):
        
        # 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

        # 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.initialized = False

        self.type = 'MV'