C2MV commited on
Commit
58d0ab0
1 Parent(s): 333a57d

Update interface.py

Browse files
Files changed (1) hide show
  1. interface.py +13 -6
interface.py CHANGED
@@ -157,22 +157,28 @@ class BioprocessModel:
157
  if model_type not in self.models:
158
  raise ValueError(f"Model type '{model_type}' is not set. Please use set_model first.")
159
 
 
160
  func = self.models[model_type]['function']
161
  params = self.models[model_type]['params']
162
 
163
  # Depuración: Asegurarse de que los parámetros estén bien definidos
164
  print(f"Fitting {model_type} model with function: {func} and parameters: {params}")
165
 
166
- # Define the fitting function based on model type
167
  def fit_func(t, *args):
168
- # Asegurarse de que se pasa el número correcto de parámetros
169
- print(f"Calling fit_func with args: {args}")
170
- return func(t, *args)
171
-
 
 
172
  # Depuración: Verificar el número de parámetros que se espera ajustar
173
  print(f"Number of parameters to fit: {len(params)}")
174
-
175
  try:
 
 
 
176
  # Intentar ajustar el modelo usando curve_fit
177
  popt, _ = curve_fit(fit_func, time, data, bounds=bounds, maxfev=10000)
178
  print(f"Optimal parameters found: {popt}")
@@ -187,6 +193,7 @@ class BioprocessModel:
187
  print(f"Error while fitting {model_type} model: {str(e)}")
188
  raise
189
 
 
190
  def plot_combined_results(self, time, biomass, substrate, product,
191
  y_pred_biomass, y_pred_substrate, y_pred_product,
192
  biomass_std=None, substrate_std=None, product_std=None,
 
157
  if model_type not in self.models:
158
  raise ValueError(f"Model type '{model_type}' is not set. Please use set_model first.")
159
 
160
+ # Función generada por lambdify
161
  func = self.models[model_type]['function']
162
  params = self.models[model_type]['params']
163
 
164
  # Depuración: Asegurarse de que los parámetros estén bien definidos
165
  print(f"Fitting {model_type} model with function: {func} and parameters: {params}")
166
 
167
+ # Definir la función de ajuste (asegurarse de que toma los parámetros correctamente)
168
  def fit_func(t, *args):
169
+ try:
170
+ return func(t, *args)
171
+ except Exception as e:
172
+ print(f"Error in fit_func: {e}")
173
+ raise
174
+
175
  # Depuración: Verificar el número de parámetros que se espera ajustar
176
  print(f"Number of parameters to fit: {len(params)}")
177
+
178
  try:
179
+ # Verifica que curve_fit puede recibir la función correctamente
180
+ print(f"Calling curve_fit with time: {time}, data: {data}, bounds: {bounds}")
181
+
182
  # Intentar ajustar el modelo usando curve_fit
183
  popt, _ = curve_fit(fit_func, time, data, bounds=bounds, maxfev=10000)
184
  print(f"Optimal parameters found: {popt}")
 
193
  print(f"Error while fitting {model_type} model: {str(e)}")
194
  raise
195
 
196
+
197
  def plot_combined_results(self, time, biomass, substrate, product,
198
  y_pred_biomass, y_pred_substrate, y_pred_product,
199
  biomass_std=None, substrate_std=None, product_std=None,