Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting optimization options after initial optimization #122

Open
dhblum opened this issue Apr 17, 2018 · 0 comments
Open

Setting optimization options after initial optimization #122

dhblum opened this issue Apr 17, 2018 · 0 comments

Comments

@dhblum
Copy link
Collaborator

dhblum commented Apr 17, 2018

This issue is to address the raising of an error when optimization options try to be changed after an initial optimization is solved. That is in something like the following:

# Instantiate optimization problem
opt_problem = optimization.Optimization(model, \
                                        optimization.EnergyMin, \
                                        optimization.JModelica, \
                                        'q_flow');
# Solve optimization problem                     
opt_problem.optimize(start_time, final_time);
# Get options
opt_options = opt_problem.get_optimization_options();
# Set new options
opt_options['IPOPT_options']['max_iter'] = 2;
opt_options['n_e'] = 2;
opt_options['result_mode'] = 'mesh_points';
opt_problem.set_optimization_options(opt_options)
# Resolve optimization problem                     
opt_problem.optimize(start_time, final_time);

It will raise the following error:

Traceback (most recent call last):
  File "/home/dhb-lx/git/mpcpy/MPCPy/unittests/test_optimization.py", line 261, in test_set_options_iterative
    opt_problem.set_optimization_options(opt_options)
  File "/home/dhb-lx/git/mpcpy/MPCPy/mpcpy/optimization.py", line 177, in set_optimization_options
    return self._package_type._set_optimization_options(opt_options);
  File "/home/dhb-lx/git/mpcpy/MPCPy/mpcpy/optimization.py", line 835, in _set_optimization_options
    raise KeyError('Key {} is set automatically upon solve.'.format(key));
KeyError: 'Key external_data is set automatically upon solve.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant