Special transformations for operators => and <=>#372
Conversation
|
Thanks for your implementation, @MarkBeB! I replaced the generic operators with the new special ones on one of my feature branches on the virtualized IHTP project and all but one worked flawlessly. I have two points for you to please consider here. 1. For one constraint, the validator did not let me use the new operator.The expression was very similar to this: If I am not mistaken, the problem is not the operator The constraint can be seen here: https://github.com/maxkratz/dissertation-ihtp/blob/520f4667abb7b0da3f9806c9e6968ebe216bd648/ihtcvirtualgipssolution/src/ihtcvirtualgipssolution/Model.gipsl#L428-L455 I thought this would fall into the first case you described above:
Can you please have a look at this? :) 2. Addition of another complex caseIf we are able to express another complex case that came up in my specification, that would help me to eliminate two additional variables and two additional constraints from the GIPSL spec. Consider the following constraint: If we define a substitute variable
to represent the term Now we can use ...
in a simplified form:
This would lead to the following complete set of replacement constraints for the new complex case above: Can you please check if this can be included in your new implementation of the shortcut operators @MarkBeB ? Sorry that it took me so long to come up with this - I did not see this (further) case coming when first replacing the operators in my spec. |
1. For one constraint, the validator did not let me use the new operator.The linked constraint doesn't match any case. It translates to: 2. Addition of another complex caseI will look into it! |
Oups, you are right! I could have sworn I checked the split of the respective constraint but ... apparently I didn't do it correctly. After splitting it (maxkratz/dissertation-ihtp@3c8a063), every case of the new operators seems to work as expected. Thanks again!
Thank you very much. |
|
Added a tooltip to the preference settings and added a comment to the comment! |
maxkratz
left a comment
There was a problem hiding this comment.
Thank you again for the nice implementation.
This PR introduces shortcut transformations for
=>and<=>and should resolve #236 .To enable these special linearisations, two new operators have been added to GIPSL:
==>and<==>.Automatic detection would have been preferable, but this isn't possible in many cases because some of the necessary information is only available at runtime (too late!).
If the operator
==>or<==>is used, the GIPSL validator will check its usage against known patterns. If no match is found, an error will be thrown.The following list contains all of the implemented patterns. Each capital letter (e.g. A) represents an arithmetic expression. Please note that it is not necessary to follow the order of operands exactly as listed. The letter
Mrefers to a 'large' enough number (which can be set viaWindow -> Preferences -> Gipsl -> Code Generator -> Big M)A >= 1 <==> B == 1 (& C == 1 & ...)Resolves to:
B (+ C + ...) + (1-n) <= A&A <= B*M (& A <= C*M & ...)A == 1 <-> B == 1 (& C == 1 & ...)Resolves to:
B (+ C + ...) + (1-n) <= A&A <= B (& A <= C & ...)A == 1 <-> B == 1 | C == 1 (| D == 1 | ...)Resolves to:
A <= B + C (+ D + ...)&B + C (+ D + ...) <= A*nA == 0 <-> B == 1Resolves to:
(1-B) <= A&A <= (1-B) * MA == 1 -> B == 1Resolves to:
A <= B