question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflicting directionality of constraint and variable value diff

See original GitHub issue

When you diff two models, the directionality (+/-) is opposite between the Constraint Differences and the Relative/Absolute Differences. I read sol2.diff(sol1) as what is the diff going sol1 --> sol2. See in the trivial example below that the Constraint Difference makes it look like the additional constraint has gone away (when it’s in fact the inverse) whereas the solution value has increased 100% (which it has).

In [1]: from gpkit import Variable, Model                                                                                                                      

In [2]: x = Variable("x")                                                                                                                                      

In [3]: m1 = Model(x, [x >= 1])                                                                                                                                

In [4]: sol1 = m1.solve()                                                                                                                                      
Solving took 0.151 seconds.

In [5]: m2 = Model(x, [x >= 1, x >= 2])                                                                                                                        

In [6]: sol2 = m2.solve()                                                                                                                                      
Solving took 0.177 seconds.

In [7]: print(sol2.diff(sol1))                                                                                                                                 
Solution Diff
=============
(positive means the argument is smaller)

Constraint Differences
**********************
--- removed in argument
+++ added in argument

@@ -6,4 +6,3 @@
 Constraints
 -----------
  x >= 1
- x >= 2

**********************

Relative Differences |above 1%|
-------------------------------
x : +100.0%

Basically comes down to the slight contradiction between (positive means the argument is smaller) and +++ added in argument.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bqpdcommented, Aug 10, 2020

d’oh I should have tried writing it out, that does work well. will implement!

0reactions
pgkirschcommented, Aug 10, 2020

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conflicting directionality
1 Introduction. Certain kinds of complex phenomena serve as testing and proving grounds in phonology as theories develop and change.
Read more >
Global Constraints
E.g., the alldiff(x1,...,xn) constraint forces that all the values of integer variables x1,...,xn must be different.
Read more >
Constraint Satisfaction Problems and Techniques
This algorithm not only removes conflicting values but also maintains. Directional arc consistency among variables.We can prune off larger.
Read more >
Auto Layout Guide: Anatomy of a Constraint - Apple Developer
Describes the constraint-based system for laying out user interface elements.
Read more >
Mass minimization with conflicting dynamic constraints by ...
The problem can be formulated as an integer optimization problem where the design variables can take the values 0 or 1, with 1...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found