OpenMDAO / dymos

Open Source Optimization of Dynamic Multidisciplinary Systems
Apache License 2.0
208 stars 66 forks source link

Failure to load an existing trajectory as an initial guess #406

Closed JorgeValderrama closed 3 years ago

JorgeValderrama commented 4 years ago

Summary of Issue

I get to run and solve my optimization problem from the Command Line Interface, but when I try to run it by loading the previous solution it fails and raises and error saying that my design parameter was already loaded as an input parameter.

Issue Type

Description

Hello, as part of my master studies I'm using Dymos for the 2D trajectory optimization of launchers under the guidance of Dr. Loïc Brevault and Dr. Mathieu Balesdent from Onera. I've been running the optimization code from Spyder getting some good results already but now I'm trying to run it from the command window to load previous results as an initial guess.

My optimization problem is executing correctly from the Command Line Interface, but when I try to load the results stored in the"dymos_solution.db" file by using the optional argument [-t SOLUTION] it fails and raises an error indicating that my design parameters had been already added as input parameters.

Example

From my files in

https://github.com/JorgeValderrama/Launcher-trajectory-optimization.git

I run from the Command Line interface

dymos main_opt_traj.py

and it works fine, but when I try to use the results as initial guess using

dymos -t dymos_solution.db main_opt_traj.py

it fails.

Environment

Operating System: Windows 10 Home Python environment: Anaconda Python 3.7.6 Packages:

robfalck commented 4 years ago

Thanks for the issue. We've been doing some significant upgrading to OpenMDAO and Dymos recently. I'm going to attempt to run this through our latest revisions and see if it still exhibits that behavior.

Kenneth-T-Moore commented 4 years ago

Just an initial note: I have a Pull Request up that fixes this issue. However, there are some additional bugs that I will fix in the follow-ons. (issue #413 ) (There are also a few changes that I needed to make in your top-level model, and we will make sure to get those back to you.)

robfalck commented 4 years ago

@JorgeValderrama do you have the git hash for your version of Dymos? We have a fix for the load case on the master branch but we have a regression which your problem uncovered, so we can just bump you up to the latest yet. If you give me the hash for your version I should be able to work up an interim branch for you.

JorgeValderrama commented 4 years ago

Thank you for your help. The output I get from "pip freeze" for Dymos v0.15.1 contains the git hash. But for the version I'm using the output for Dymos is only "dymos==0.15.0" . Is there any other way to get the git hash?

robfalck commented 4 years ago

If you cloned the dymos repo you should be able to do a git log. We're working to address the issues your case uncovered.

JorgeValderrama commented 3 years ago

Hello, apologize for my late answer.

I used pip install from Spyder to install Dymos, I didn't clone the repo. For this reason, I’m not able to access the list of commits using “git log”.

I tried to follow a procedure from Stack Overflow (link below) to compare my installed version and the one available in your github using “git diff” but it hasn’t worked. I keep getting an error (message below).

On the other hand, I was able to code a function to read the “dymos_solution.db” file, extract the final iteration and use it as initial guess, so I can keep working with the version I have from Dymos 0.15.0.

Thank you for offering to work up the interim branch, but I’m new to git and haven’t been able to retrieve the hash. Next time I will clone the repo.

Thread on stack over flow: https://stackoverflow.com/questions/45681223/how-can-i-know-which-commit-was-used-when-installing-a-pip-package-from-git

Error message when executing “git fetch foreign”: fatal: unable to access 'https://github.com/OpenMDAO/dymos.git@0.15.0/': The requested URL returned error: 400

robfalck commented 3 years ago

This should be working as of 0.16.0, but there are a few catches to your case that we're still working on.

You pass the final value of a variable from one phase to the value of a parameter in another phase. The way parameters are handled now is more memory efficient, but a bug prevents passing to a parameter with src_indices. This will be addressed in OpenMDAO 3.4.1 (due out in the next few days).

JorgeValderrama commented 3 years ago

All right, I will keep working on 0.15.0 as it can do what I need now and somewhere in the future if I migrate to those newer versions of Dymos and OpenMDAO I will let you know If I succeed to load the trajectory. Thank you for your assistance.

robfalck commented 3 years ago

This should be working correctly now.