SMTorg / smt

Surrogate Modeling Toolbox
https://smt.readthedocs.io/en/stable
BSD 3-Clause "New" or "Revised" License
673 stars 202 forks source link

Question About KeyError: 'design_space' #601

Closed ilaudo closed 2 months ago

ilaudo commented 3 months ago

Hello there, I am trying to implement the KRG() function into an optimal control problem using Dymos. I have trained my Kriging models on a large set of data which requires three inputs and one output. However, each time that I try to call the .predict_values() method in my optimal control code, I receive a KeyError: 'design_space'. My guess thusfar is that the kriging models do not believe they have been trained on continuous data, however, I am unsure. It should be noted that I have my Kriging models saved in .pickle files to prevent them from being retrained each iteration. This code worked perfectly fine up until one day ago, in which it started acting rather odd. I appreciate the help! Here is the function call I use: CL = smt.predict_values(inputValues) where inputValues has a dimension of (nn, 3) and CL has a dimension of (nn, 1).

Here is the full error printout: Traceback (most recent call last):

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/openmdao/core/system.py:2666 in _call_user_function
    yield

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/openmdao/core/explicitcomponent.py:267 in _compute_wrapper
    self.compute(self._inputs, self._outputs)

  File ~/Documents/HypersonicMDA-main/ClimbTraj.py:126 in compute
    CL = sml.predict_values(inputValues)

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/smt/surrogate_models/krg_based.py:1433 in predict_values
    y = self._predict_values(x2, is_acting=is_acting)

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/smt/surrogate_models/krg_based.py:1457 in _predict_values
    if not (self.is_continuous):

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/smt/surrogate_models/krg_based.py:260 in is_continuous
    return self.design_space.is_all_cont

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/smt/surrogate_models/krg_based.py:246 in design_space
    if self.options["design_space"] is None:

  File ~/anaconda3/envs/StratoLaunchProject/lib/python3.10/site-packages/smt/utils/options_dictionary.py:52 in __getitem__
    return self._dict[name]

KeyError: 'design_space'
relf commented 3 months ago

Did you change the SMT version? What version do you use? Looks like your pickle files were generated with an old version without the design_space property which was added in release 2.0. Either you retrain your models and save the pickle files with your current version (2.x?) of SMT or you downgrade to the version (1.3?) you used to generate the pickles.