"""

One model among many
====================

We consider the model with 432 specifications defined in
:ref:`everything_spec_section`. We select one specification and estimate it.
See `Bierlaire and Ortelli (2023)
<https://transp-or.epfl.ch/documents/technicalReports/BierOrte23.pdf>`_.

Michel Bierlaire, EPFL
Sun Apr 27 2025, 18:38:30
"""

from IPython.core.display_functions import display

import biogeme.biogeme_logging as blog
from biogeme.biogeme import BIOGEME
from biogeme.results_processing import get_pandas_estimated_parameters
from everything_spec import av, database, model_catalog

logger = blog.get_screen_logger(level=blog.INFO)

# %%
# The code characterizing the specification should be copied from the
# .pareto file generated by the algorithm, or from one of the
# glossaries illustrated in earlier examples.
SPEC_ID = (
    'asc:GA-LUGGAGE;'
    'b_cost_gen_altspec:generic;'
    'b_time:FIRST;'
    'b_time_gen_altspec:generic;'
    'model_catalog:logit;'
    'train_tt_catalog:power'
)

# %% The biogeme object for the selected model can be obtained from
# the spec_id, and used as usual.
the_biogeme = BIOGEME.from_configuration(
    config_id=SPEC_ID,
    multiple_expression=model_catalog,
    database=database,
)
the_biogeme.model_name = 'my_favorite_model'

# %%
# Calculate of the null log-likelihood for reporting.
the_biogeme.calculate_null_loglikelihood(av)

# %%
# Estimate the parameters.
results = the_biogeme.estimate()

# %%
print(results.short_summary())

# %%
# Get the results in a pandas table
pandas_results = get_pandas_estimated_parameters(
    estimation_results=results,
)
display(pandas_results)
