Data at times the model writes no output for are refused or fitted depending on where the clock starts, the fit type, and how t_end is written

Abierto
#1,062 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend, testing

Línea de trabajo

Start with objective.matching_row and Configuration._refuse_data_without_rows, then compare the constraint matching in constraint._crossing_indices and output grid handling in bngsim_model.grid.kept_output_rows. Run the named strict xfail tests in tests/test_ms_review14_segments.py and tests/test_ms_review15_segments.py to reproduce the time-base, fit-type, constraint, and t_end cases. Done means the tests pass and data and constraints are handled consistently across time bases, fit types, and equivalent t_end expressions.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

What you do. Fit data at times the model does not write output at. For example, a model whose action writes a row every 1.0 (n_steps too small) and data every 0.25.

What you see. Whether that is an error depends on where the clock starts, on the fit type, and on how t_end is spelled. It should depend on none of them.

  • Where the clock starts. With t_start=>100 the configuration is refused as it loads: "the data for "tc" has t = 100.25, ... where the action writes no row". With t_start=>100000 and nothing else changed, it loads and fits. gntr and de score each datum against the nearest whole-number row and report k = 1.0686. The data's own optimum is k = 1.0063 (scipy on the closed form).
  • The fit type. In that same job, job_type = ms reports k = 1.0063. It simulates at each datum's own time and never reads the action's rows. So two fit types report two best fits for one configuration, with no message from either.
  • How t_end is spelled. With t_start=>0, t_end=>2 every fit type refuses the job at load. With t_end=>1+1, the output times are not worked out at load. Then gntr stops at its first evaluation ("time=0.25 ... is not in the simulation output"), and ms fits it.
  • Constraints. A constraint at time = T, with T three quarters of the way between two rows, reads the earlier row (PyBNF's documented convention) when the time base is 0, 100 or 1e4. From 1e5 on, it reads the later row. On a trajectory whose value is ten times its row number, the penalty of A < 0 at time = T is 20 at the lower bases and 30 at the higher ones.

Why. A datum is matched to a simulated row when the two times agree to within 1e-5 of the time, numpy's default relative tolerance. That is deliberate: a time written to six significant digits, such as 10.1667 for 10 h 10 min, has to match its row at 10.16666.... But the tolerance grows with the time. Far enough from t = 0 it is wider than the step between rows, so a datum between two rows is matched to one of them instead of being refused. The constraints' own time match does the same.

What should happen. Whether a datum or a constraint time has a row should not depend on the time base, the fit type, or how the action's arguments are written. A tolerance alone cannot decide it. An attempt during review of fix/ms-batch required a row to be within a thousandth of the row spacing, as well as within the relative tolerance. That refused valid data: a per-minute 24 h course with times written to six digits lost 56 of its 145 data. It was reverted before merge. Two other directions:

  • Have the simulator write output at each data time, as ms already does. Then there is nothing to match.
  • Refuse at load when the relative tolerance at a datum's time is wider than the step between rows, unless the datum is on a row.

The second is narrower, but on its own it refuses jobs on a late time base that load today.

Where.

  • objective.matching_row (the objective and the load-time check Configuration._refuse_data_without_rows).
  • constraint._crossing_indices.
  • bngsim_model.grid.kept_output_rows, which gives up when an action argument is an expression such as 1+1.
  • ms scores segments at the data's own times (pybnf/shooting/).

Reproduction. These tests are in the branch as strict xfails:

  • tests/test_ms_review14_segments.py: test_a_datum_between_two_simulated_rows_is_refused_at_any_time_base, test_data_finer_than_the_models_output_grid_is_refused_on_a_late_time_base and test_ms_and_gntr_report_one_fit_for_one_configuration_on_a_late_time_base.
  • tests/test_ms_review15_segments.py: the constraint and t_end=>1+1 cases.

The model is A() -> 0 at k_deg from A = 1, with simulate({method=>"ode",t_start=>100000,t_end=>100002,n_steps=>2,suffix=>"tc"}), and data every 0.25 from 100000 to 100002. The job:

edition = 2
bngl_backend = bngsim
model = m.bngl : tc.exp
objective = sos
uniform_var = k_deg 0.1 10
job_type = gntr

Found during review of the multiple-shooting batch (fix/ms-batch). The behaviour is the same on main, except that main also matched a datum to the first row within the tolerance rather than the nearest one. fix/ms-batch fixes that.

Lenguaje dominante
Python
Estrellas
26
Forks
25
Merge medio
4 h 25 min
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lanl/PyBNF

Todos los issues de lanl/PyBNF

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.