Repository navigation
Fix design vector size in the CG, BFGS and POWELL optimizers - #3064
Open
SahilKumar965 wants to merge 1 commit into
Open
SahilKumar965 wants to merge 1 commit into
SahilKumar965 wants to merge 1 commit into
Conversation
scipy_cg, scipy_bfgs and scipy_powell counted one design variable per DEFINITION_DV entry and prescaled x0 per entry. Entries can hold more than one value (an FFD_CONTROL_POINT_2D with direction (0, 0) has size 2, an FFD_CONTROL_POINT with (0, 0, 0) has size 3), so with those the optimizer passed a too short design vector and unpack_dvs stopped with "unexpected design vector length". Count the design variables with sum(SIZE) like scipy_slsqp and Config.unpack_dvs, and prescale each value with the scale of its entry. Nothing changes when all entries have size 1.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
scipy_cg, scipy_bfgs and scipy_powell use
n_dv = len(DEFINITION_DV["KIND"]), so they count one design variable per entry. But some entries have more than one value, e.g. an FFD_CONTROL_POINT_2D with direction (0, 0) has size 2 and an FFD_CONTROL_POINT with (0, 0, 0) has size 3. In that case these optimizers pass a design vector that is too short and unpack_dvs stops with "unexpected design vector length". The x0 prescaling has the same problem.SLSQP already does this right with
sum(SIZE), so I changed the other three the same way and prescale x0 value by value with the scale of its entry.I tested it with three DV entries of size 1, 2 and 3 (scales 1, 0.5, 2) and checked the vector each optimizer passes at the first evaluation:
When all entries have size 1 the result is the same as before.
Related Work
No issue for this one. Found it while looking at #3054 / #3056.
PR Checklist
pre-commit run --allto format old commits.