0

I have set up a couple problems in openMDAO, I want to extract the "params" vector for one, and use that to set the input for another. Basically the first optimizes some stuff, then I want to use that solution in another problem to do something else (see Implementing AMMF within OpenMDAO).

I am trying to make this general where I do not have to explicitly name the variables that need to be exchanged. This way if the two problems take the same variables as inputs it should just work...

Now when I run the problem, I can access a params member from the group, but that params is initialized with the default values. Not the values of the last run. So how do I get that vector?

I guess a second part to this questions is how can you "set" all the parameters in one operation.

  • Silly limitation of stack overflow is that I cannot use the word problem in the title. I get it, but what if I want to refer to an openMDAO object called problem?
Community
  • 1
  • 1
Mike McWilliam
  • 166
  • 1
  • 9
  • your question is a little vauge. It would help a lot if you constructed a simple example to go with the problem. – Justin Gray Feb 17 '16 at 13:08
  • In my PhD I created something similar to openMDAO but in C++... not as sophisticated and it did things a little different. I had get/set methods that collected/set the entire design vector despite the fact that the actual values were stored within objects. So I was hoping I could do something like that with openMDAO – Mike McWilliam Feb 17 '16 at 14:10
  • I have to run... but I will clarify my problem a little later... – Mike McWilliam Feb 17 '16 at 14:10

1 Answers1

0

Typically you should not need to access the params vector of a Problem in almost any situation. You should only need to interact with the unknowns vector, which you can do via the Problem itself (e.g. prob['some_var']).

In your case, to make something totally automatic, based on naming only, you might actually need to get the unknowns vector itself, from the root group (root.unknowns).You can loop over that like a dictionary, and get (var_name, meta_data) pairs. You can use that to get the variable value and then use it to set the same variable name in whatever downstream problem you wish to use.

If you assume that the two problems are totally, identical, you could just blindly loop over all the values in the unknowns dictionary. But if they are not the same, but just have SOME of the same variable names, you'll have to be a bit more cautious and check to see if the variable from the first problem exists in the second.

Justin Gray
  • 5,605
  • 1
  • 11
  • 16