Reputation: 33
The link below about a SimpleGADriver document in OpenMDAO describes "Default is an empty dict, where every unspecified variable is assumed to be an integer, and the number of bits is calculated automatically"
In the example in the document, "xI" value is calculated in the optimization process as an integer value with the range from -5 to 10.
However, When I change the range from -6 to 11 (Not the length of 2^(n)), "xI" value is calculated as a real value.
Although the "xI" value is unspecified variable, it seems the bits of the value is not calculated automatically as mentioned in the document.
[The example in the document]
from openmdao.api import Problem, Group, IndepVarComp, SimpleGADriver
from openmdao.test_suite.components.branin import Branin
prob = Problem()
model = prob.model = Group()
model.add_subsystem('p1', IndepVarComp('xC', 7.5))
model.add_subsystem('p2', IndepVarComp('xI', 0.0))
model.add_subsystem('comp', Branin())
model.connect('p2.xI', 'comp.x0')
model.connect('p1.xC', 'comp.x1')
model.add_design_var('p2.xI', lower=-5.0, upper=10.0)
model.add_design_var('p1.xC', lower=0.0, upper=15.0)
model.add_objective('comp.f')
prob.driver = SimpleGADriver()
prob.driver.options['bits'] = {'p1.xC': 8}
prob.setup()
prob.run_driver()
Is there any solution for the "xI" integer value even if its range is changed?
Upvotes: 3
Views: 146
Reputation: 2202
This is a bug, and it has been added to the tracker.
A workaround for now would be to choose a range (max - min) that is a power of two, but is larger than the range you want, and then modify your component to either:
or
Upvotes: 2