convexengineering / SPaircraft

Models for commercial aircraft design
http://spaircraft.readthedocs.org
25 stars 17 forks source link

Using realxed solution as initial guess for non-realxed solution #30

Closed mayork closed 7 years ago

mayork commented 7 years ago

@bqpd this is not as straight forward as simply setting x0 equal to sol['variables'] because some variables, as a by product of vectorization, are stored like this

sol['variables']['C_D']
Out[9]: 
{C_D_Mission.2, ClimbSegment.2, ClimbP.2, AircraftP.4: array([ 0.02883003,  0.0294485 ,  0.02911134,  0.02907055,  0.02906814]),
 C_D_Mission.2, CruiseSegment.2, CruiseP.2, AircraftP.5: array([ 0.02872351,  0.02686378])}

so an error with traceback messages such as this

/Users/mayork/Documents/GpGit/gpkit/gpkit/nomials/nomial_math.pyc in mono_approximation(self, x0)
    181         x0, _, _ = parse_subs(self.varkeys, x0)  # use only varkey keys
    182         exp = HashVector()
--> 183         psub = self.sub(x0)
    184         if psub.varlocs:
    185             raise ValueError("Variables %s remained after substituting x0=%s"

/Users/mayork/Documents/GpGit/gpkit/gpkit/nomials/nomial_math.pyc in sub(self, substitutions, require_positive)
    217         Returns substituted nomial.
    218         """
--> 219         _, exps, cs, _ = substitution(self, substitutions)
    220         return Signomial(exps, cs, require_positive=require_positive)
    221 

/Users/mayork/Documents/GpGit/gpkit/gpkit/nomials/substitution.pyc in substitution(nomial, substitutions)
    108         return nomial.varlocs, nomial.exps, nomial.cs, substitutions
    109 
--> 110     subs, _, _ = parse_subs(nomial.varkeys, substitutions)
    111 
    112     if not subs:

/Users/mayork/Documents/GpGit/gpkit/gpkit/nomials/substitution.pyc in parse_subs(varkeys, substitutions)
     27             if key in varkeys.keymap:
     28                 sub, keys = substitutions[var], varkeys.keymap[key]
---> 29                 append_sub(sub, keys, constants, sweep, linkedsweep)
     30     return constants, sweep, linkedsweep
     31 

/Users/mayork/Documents/GpGit/gpkit/gpkit/nomials/substitution.pyc in append_sub(sub, keys, constants, sweep, linkedsweep)
     62                                  " variable %s of shape %s." %
     63                                  (sub.shape, key.str_without("model"),
---> 64                                   key.shape))
     65 
     66         if hasattr(value, "__call__") and not hasattr(value, "key"):

ValueError: cannot substitute array of shape () for variable RngClimb_Mission.2, ClimbSegment.2, ClimbP.2_(3,) of shape (5,).

occurs. what is your recommended path around this? Writ a short script that detects solution entries that isn't a quantity and makes them into a quantity?

bqpd commented 7 years ago

This looks like it might be a 0-d array bug on my end.

bqpd commented 7 years ago

@mayork What commit and file reproduce this?

mayork commented 7 years ago

didn't push it but the code at fd875543c2496b shows the method (throws a slightly different error but I think it's also a GPkit bug)

bqpd commented 7 years ago

What file?

mayork commented 7 years ago

D8.py

bqpd commented 7 years ago

It seems to be solving?

bqpd commented 7 years ago

Nvm, caught it

mayork commented 7 years ago

we're solving without any relaxed constants after approx GP iteration 3 so i'm closing this, don't think we need the functionality. @1ozturkbe if you disagree feel free to reopen.