Skip to content

simplify and fix sensitivites, add test#1064

Merged
bqpd merged 2 commits intomasterfrom
fixsenssright
Mar 6, 2017
Merged

simplify and fix sensitivites, add test#1064
bqpd merged 2 commits intomasterfrom
fixsenssright

Conversation

@bqpd
Copy link
Copy Markdown
Contributor

@bqpd bqpd commented Feb 28, 2017

Closes #1060

@whoburg, ready for review.

@bqpd
Copy link
Copy Markdown
Contributor Author

bqpd commented Feb 28, 2017

test models please

Copy link
Copy Markdown
Collaborator

@whoburg whoburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing it right!

Please address inline comments before merging.

self.assertAlmostEqual(senss[R], 0.41, 2)
self.assertAlmostEqual(senss[fuel_per_nm], 0.41, 2)
self.assertAlmostEqual(senss[W_payload], 0.39, 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

[x >= 1,
y == 2])
m.solve(verbosity=0)
m.solve(solver=self.solver, verbosity=0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

for exp in zeroed_terms:
del matches[exp]
if not matches: # it's a zero monomial
matches[HashVector()] = 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, why do we need to set matches[HashVector()] = 0 here? I would have thought we just let exps_ = (), and cs = [] (and therefore mmap = [] if returned) in that case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in the current scheme; the current abstraction for simplification is Bad, but this wasn't the PR to fix it...

exps_.pop(i)
exps = tuple(exps_)
if pmap is not None:
self.const_mmap = pmap.pop(i) # pylint: disable=attribute-defined-outside-init
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, this mutates pmap? That ought to be documented.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and is that really intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes.

self._last_used_substitutions = subs
exps, cs = self._simplify_posy_ineq(exps, cs)
exps, cs, pmap = simplify_exps_and_cs(exps, cs, return_map=True)
exps, cs, pmap = self._simplify_posy_ineq(exps, cs, pmap)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot going on in the four lines above (substitution, and two simplification steps). Can you add an inline comment to clarify what the two different simplification steps are? Or perhaps make the method names more descriptive?

It's particularly interesting to me that the two simplification steps switched order in this PR -- what's up with that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what most of the work of this PR goes into, is designing self._simplify_posy_ineq so that it allows that. Thus we end up with an mmap for the constant term that can be noted during constraint simplification.

@bqpd
Copy link
Copy Markdown
Contributor Author

bqpd commented Mar 6, 2017

Added comments per review.

@bqpd bqpd merged commit 209cb15 into master Mar 6, 2017
@bqpd bqpd deleted the fixsenssright branch March 6, 2017 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants