Rapid-Design-of-Systems-Laboratory / beluga

General purpose indirect trajectory optimization
Other
25 stars 6 forks source link

ValueError: setting an array element with a sequence. on productspace step #212

Closed dHannasch closed 4 years ago

dHannasch commented 4 years ago

When trying to run examples/AtmosphericFlight/Hypersonic3DOF/hypersonic3DOF.py with an added productspace step, it crashes with "ValueError: setting an array element with a sequence."

This is the only alteration to hypersonic3DOF.py:

    continuation_steps.add_step('productspace') \
        .const('theta_f', (2.6*pi/180, 3.6*pi/180, 10)) \
        .const('phi_f', (1.85*pi/180, 2.25*pi/180, 5))

This is the ValueError:

self = <beluga.continuation.continuation.ProductStrategy object at 0x7fd6f20e2790>
ignore_last_step = False

    def next(self, ignore_last_step=False):
        if len(self.gammas) is 0:
            raise ValueError('No boundary value problem associated with this object')

        if not ignore_last_step and len(self.gammas) is not 1 and not self.gammas[-1].converged:
            logging.error('The last step did not converge!')
            raise RuntimeError('Solution diverged! Stopping.')

        if self.ctr >= self.num_cases():
            raise StopIteration

        # Update auxiliary variables using previously calculated step sizes
        total_change = 0.0
        const0 = copy.deepcopy(self.gammas[-1].const)
        for var_name in self.vars:
            jj = self.bvp.raw['constants'].index(var_name)
>           const0[jj] = self.vars[var_name].steps[self.ctr]
E           ValueError: setting an array element with a sequence.

beluga/continuation/continuation.py:120: ValueError
msparapa commented 4 years ago

productspace only takes in a single end point for each variable. We can't provide two points yet. Nor can we define a different subdivision amount for each variable.

I think you'd need to change

continuation_steps.add_step('productspace') \
    .const('theta_f', (2.6*pi/180, 3.6*pi/180, 10)) \
    .const('phi_f', (1.85*pi/180, 2.25*pi/180, 5))

to

continuation_steps.add_step('productspace') \
    .num_subdivisions(10) \
    .const('theta_f', 3.6*pi/180) \
    .const('phi_f', 2.25*pi/180)

Before you run product space, make sure the previous bisection strategy ends at theta_f = 2.6pi/180 and phi_f = 1.85pi/180.

Otherwise productspace should be behaving as expected.