Update interface.py
Browse files- 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 |
-
#
|
| 167 |
def fit_func(t, *args):
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 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,
|