Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
d = var_dict.copy()
d['name'] = var + '(Tr)'
self.gekko_data['vars']['variables'].append(d)
if main_dict[var].name + '.bcv' in self.results:
d1 = var_dict.copy()
d1['name'] = var + '_hist(bias)'
self.gekko_data['vars']['variables'].append(d1)
d2 = var_dict.copy()
d2['name'] = var + '_hist(nobias)'
self.gekko_data['vars']['variables'].append(d2)
d3 = var_dict.copy()
d3['name'] = var + '(nobias)'
self.gekko_data['vars']['variables'].append(d3)
elif isinstance(main_dict[var], GKParameter):
self.gekko_data['vars']['parameters'].append(var_dict)
if isinstance(main_dict[var], (GK_MV, GK_FV)):
d = var_dict.copy()
d['name'] = var + '_hist'
self.gekko_data['vars']['parameters'].append(d)
elif isinstance(main_dict[var], GK_Intermediate):
self.gekko_data['vars']['intermediates'].append(var_dict)
# Update the variable if the data has been loaded before
data = False
if isinstance(main_dict[var], GKVariable):
self.get_variable_fron_main(var)
return
elif isinstance(main_dict[var], GKParameter):
self.get_parameter_from_main(var)
return
elif isinstance(main_dict[var], GK_Intermediate):
data = list(filter(lambda d: d['name'] == var, self.gekko_data['vars']['intermediates']))[0]
def MV(self, value=None, lb=None, ub=None, integer=False, fixed_initial=True, name=None):
"""Change these variables optimally to meet objectives"""
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_MV(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