Tengo este error al intentar cargar la solucion al problema jackson_basic de BOCOP en la clase BOCOPSolution. Parece ser que el numero datos en la discretizacion del tiempo es diferente a los valores de alguna de las soluciones.
ValueError Traceback (most recent call last)
Input In [87], in <cell line: 1>()
----> 1 a_tf_0_7_tf_5 = BOCOPSolution("sol/1")
File ~\anaconda3\envs\nn\lib\site-packages\bocop_solution.py:58, in BOCOPSolution.init(self, working_directory_filename)
56 controls = [file for file in files if f"stage_{file}" in files]
57 # Creating bunch objects for each variable type
---> 58 self.adjoint_states = _AdjointStates(self, states)
59 self.states = _States(self, states)
60 self.controls = _Controls(self, controls)
File ~\anaconda3\envs\nn\lib\site-packages\internals_bunches.py:12, in _AdjointStates.init(self, solution, variable_list)
11 def init(self, solution: BOCOPSolution, variable_list: list[str]):
---> 12 super().init(solution, [f"{variable}_adjoint_state" for variable in variable_list])
File ~\anaconda3\envs\nn\lib\site-packages\internals_variable_bunch.py:31, in _VariableBunch.init(self, solution, variable_list)
23 def init(self, solution: BOCOPSolution, variable_list: list[str]):
24 """
25 Parameters
26 ----------
(...)
29 variable_list: list[str]
30 A list with each variable named."""
---> 31 self.variables = {name: _Variable(solution, name) for name in variable_list}
32 self.working_directory_filename = solution.working_directory_filename
33 self.dataframe = pd.DataFrame({name: variable.series
34 for name, variable in self.variables.items()})
File ~\anaconda3\envs\nn\lib\site-packages\internals_variable_bunch.py:31, in (.0)
23 def init(self, solution: BOCOPSolution, variable_list: list[str]):
24 """
25 Parameters
26 ----------
(...)
29 variable_list: list[str]
30 A list with each variable named."""
---> 31 self.variables = {name: _Variable(solution, name) for name in variable_list}
32 self.working_directory_filename = solution.working_directory_filename
33 self.dataframe = pd.DataFrame({name: variable.series
34 for name, variable in self.variables.items()})
File ~\anaconda3\envs\nn\lib\site-packages\internals_variable.py:46, in _Variable.init(self, solution, name)
44 times = solution.stage_times if len(solution.stage_times) == len(self.values) else solution.discretization_times
45 self.discretization_times = times
---> 46 self.series = pd.Series(self.values, index=self.discretization_times, name=name)
47 # Creating the interpolator object
48 self.cubic_interpolator = scipy.interpolate.InterpolatedUnivariateSpline(self.discretization_times, self.values)
File ~\anaconda3\envs\nn\lib\site-packages\pandas\core\series.py:442, in Series.init(self, data, index, dtype, name, copy, fastpath)
440 index = default_index(len(data))
441 elif is_list_like(data):
--> 442 com.require_length_match(data, index)
444 # create/copy the manager
445 if isinstance(data, (SingleBlockManager, SingleArrayManager)):
File ~\anaconda3\envs\nn\lib\site-packages\pandas\core\common.py:557, in require_length_match(data, index)
553 """
554 Check the length of data matches the length of the index.
555 """
556 if len(data) != len(index):
--> 557 raise ValueError(
558 "Length of values "
559 f"({len(data)}) "
560 "does not match length of index "
561 f"({len(index)})"
562 )
ValueError: Length of values (400) does not match length of index (401)