text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

                     @variable(m, -1 <= x[i=1:2] <= 1)

                     @variable(m, -47.221875796417265 <= q <= 49.11122836315772)

                     add_NL_constraint(m, :(softplus(0.42790162605340454 + 0.9948146339173967*softplus(0.30429674417798 + 0.01326158862793747*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8506753528903843*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7699605184902198*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9481609482474158*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + 0.5690258167368487*softplus(0.4003333530904172 + 0.4565361301167439*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.41218949132242644*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6719961553691296*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9454422589116072*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.632632285898699*softplus(-0.4740061987673023 + -0.21503151130953757*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7641417558802628*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8796988576372375*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6466469730144713*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.0799939753544896*softplus(-0.9533597279323933 + 0.019939841305541606*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.8134733780415981*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.10348468441851777*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.008542712959329624*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))))) + softplus(-0.31282642357163937 + 0.400776902433146*softplus(0.30429674417798 + 0.01326158862793747*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8506753528903843*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7699605184902198*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9481609482474158*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.8700113611274283*softplus(0.4003333530904172 + 0.4565361301167439*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.41218949132242644*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6719961553691296*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9454422589116072*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.8173535730312884*softplus(-0.4740061987673023 + -0.21503151130953757*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7641417558802628*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8796988576372375*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6466469730144713*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.10383649475667989*softplus(-0.9533597279323933 + 0.019939841305541606*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.8134733780415981*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.10348468441851777*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.008542712959329624*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))))) + softplus(0.07748802701261592 + -0.48287575350847955*softplus(0.30429674417798 + 0.01326158862793747*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8506753528903843*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7699605184902198*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9481609482474158*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + 0.9032398979921337*softplus(0.4003333530904172 + 0.4565361301167439*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.41218949132242644*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6719961553691296*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9454422589116072*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + 0.8154202752057489*softplus(-0.4740061987673023 + -0.21503151130953757*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7641417558802628*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8796988576372375*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6466469730144713*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + 0.8885160528665201*softplus(-0.9533597279323933 + 0.019939841305541606*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.8134733780415981*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.10348468441851777*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.008542712959329624*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))))) + softplus(0.6389491685818425 + -0.9024035564379238*softplus(0.30429674417798 + 0.01326158862793747*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8506753528903843*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7699605184902198*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9481609482474158*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.8688708754259227*softplus(0.4003333530904172 + 0.4565361301167439*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.41218949132242644*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6719961553691296*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.9454422589116072*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + -0.9399903753655909*softplus(-0.4740061987673023 + -0.21503151130953757*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.7641417558802628*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.8796988576372375*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.6466469730144713*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2])))) + 0.5656846187923494*softplus(-0.9533597279323933 + 0.019939841305541606*softplus(0.7020479917236249 + 0.5157446936496526*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.8162922098274223*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6507571114046486*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + 0.3903970834590602*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.8134733780415981*softplus(0.7594455380381384 + 0.9088497207479063*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + 0.34867162336420376*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + -0.586942758624089*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.05285512797069236*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + -0.10348468441851777*softplus(0.5333438081093944 + -0.9884706408297048*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.9213430875393112*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.6584439947423988*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.39397409418232554*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))) + 0.008542712959329624*softplus(-0.8688273038537231 + -0.5762764679031651*softplus(-0.990780872931377 + 0.7098282678057655*$(x[1]) + -0.9123645360112271*$(x[2])) + -0.4115583086286181*softplus(-0.26001558800187974 + -0.2578347550825866*$(x[1]) + -0.8440952761970419*$(x[2])) + 0.07598378122288318*softplus(0.6359235954642828 + 0.0835591752979501*$(x[1]) + -0.4064923799931912*$(x[2])) + -0.5005567670062852*softplus(0.919513762198326 + -0.48206842436164976*$(x[1]) + 0.2512150299638187*$(x[2]))))) - $q <= 0.0))

                     @objective(m, Min, q)

                     return m

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
#!/usr/bin/env julia
# Tim Sterne-Weiler 2015

const dir = abspath( splitdir(@__FILE__)[1] )
const ver = chomp(readline(open(dir * "/VERSION")))

tic()
println( STDERR, "Whippet $ver loading and compiling... " )

using ArgParse

push!( LOAD_PATH, dir * "/../src" )
using Whippet
using BioAlignments
using Libz

function parse_cmd()
  s = ArgParseSettings()

  @add_arg_table s begin
    "--kmer", "-k"
      help = "Kmer size to use for exon-exon junctions (default 9)"
      arg_type = Int64
      default  = 9
    "--fasta"
      help = "File containg the genome in fasta, one entry per chromosome [.gz]"
      arg_type = String
      required = true
    "--gtf"
      help = "Gene anotation file in GTF format"
      arg_type = String
    "--bam"
      help = "Sorted and Indexed BAM file to supplement index with de novo splice-sites/exons/retained-introns. (Must have corresponding .bai file)"
      arg_type = String
    "--index", "-x"
      help = "Output prefix for saving index 'dir/prefix' (default Whippet/index/graph)"
      arg_type = String
      default  = "$dir/../index/graph"
    "--suppress-low-tsl"
      help = "Ignore low quality transcript annotations with TSL2+"
      action   = :store_true
    "--bam-min-reads"
      help = "Minimum number of reads supporting a splice-site from BAM to include in index."
      arg_type = Int
      default  = 1
    "--bam-both-novel"
      help = "Allow spliced reads from BAM where neither of the splice-sites are known (default off)."
      action   = :store_true
  end
  return parse_args(s)
end

function main()

   args = parse_cmd()

   println(STDERR, " $( round( toq(), 6 ) ) seconds." )

   if args["gtf"] == nothing
      println(STDERR, "ERROR: Must supply gene annotation file using `--gtf`!!")
      exit(1)
   else
      annotype = "gtf"
      annotxt  = "GTF"
   end

   flat = fixpath( args[annotype] )
   println(STDERR, "Loading $annotxt file: $flat")
   fh = open( flat , "r")
   if isgzipped( flat )
      fh = fh |> x->ZlibInflateInputStream(x, reset_on_end=true)
   end

   if args["bam"] != nothing
      bam = fixpath( args["bam"] )
      isfile(bam) || error("ERROR: --bam parameter used, but cannot find .bam file at $bam !")
      isfile(bam * ".bai") || error("ERROR: --bam parameter used, but no .bai index found for .bam file! Cannot set-up random access to $bam !")
      println(STDERR, "Loading BAM file for random-access: $bam")
      bamreadr = open(BAM.Reader, bam, index=bam * ".bai")
      @timer ref = load_gtf(fh, suppress=args["suppress-low-tsl"],
                                usebam=true,
                                bamreader=Nullable(bamreadr),
                                bamreads=args["bam-min-reads"],
                                bamoneknown=!args["bam-both-novel"])
   else
      @timer ref = load_gtf(fh, suppress=args["suppress-low-tsl"])
   end

   println(STDERR, "Indexing transcriptome...")
   @timer graphome = fasta_to_index( fixpath( args["fasta"] ), ref, kmer=args["kmer"] )

   println(STDERR, "Serializing splice graph index...")
   indexname = hasextension(args["index"], ".jls") ? args["index"] : args["index"] * ".jls"
   open(indexname, "w") do io
      @timer serialize( io, graphome )
   end

   println(STDERR, "Printing a map of Whippet nodes to putative full exons... $(args["index"] * ".exons.tab.gz")")
   output_exons( args["index"] * ".exons.tab.gz", graphome )

end

@timer main()

ext: jl


text:
using Test

import JavaCall
import JavaCall: JNI

opts = JavaCall.forjavahome(JAVA_HOME)
JavaCall.pushclasspath!(opts, "$(@__DIR__)/java")
JavaCall.init(opts)

@test JNI.is_jni_loaded()
@test JNI.is_env_loaded()

macro test_false(expr)
    esc(:(@test !($expr)))
end

macro test_nothing(expr)
    esc(:(@test ($expr) === nothing))
end

function _test_not_cnull(exprs...)
    for expr in exprs
        @test (expr) != C_NULL
    end
end

macro test_not_cnull(exprs...)
    esc(Expr(:call, :_test_not_cnull, exprs...))
end

function _test_isa(type, syms...)
    for sym in syms
        @test (sym) isa type
    end
end

macro test_isa(exprs...)
    type = exprs[end]
    syms = exprs[1:end-1]
    esc(Expr(:call, :_test_isa, type, syms...))
end

macro test_passed()
    @test true
end


text:
"""
    heur_solution(inst::Instance)

Computes a heuristic solution schedule, satisfying all hard constraints
minimizing the panalties

# Arguments
-`inst::Instance` - the problem instance

# Description
The heuristic first generates a start solution, satisfying all base constraints.
Then a Tabu Search algorithm is used to minimize the penalty induced by the hard
constraints of `inst`.
"""
function heur_solution(
    inst::Instance;
    maxbreaks = 3,
    maxiter = 1000,
    infeaslength = 5,
    tabulength = 20,
    lastfeaslength = 50,
    gamtimelimit = 1200.0,
    maxphases = 20,
    inithardpen = 100,
    relaxphased = true,
    start = nothing,
)
    # compute initial solution satisfyng all pattern & patternset constraints
    if start === nothing
        schedbuf = Matrix{Int}(undef, inst.rr2.nteams, inst.rr2.nslots)
        start = pgba_heuristic(
            inst,
            maxbreaks,
            schedbuf;
            gamtimelimit = gamtimelimit,
        )
    end
    start::Matrix{Int}

    if inst.rr2.isphased && relaxphased
        phasedcons = Vector{Constraint}()
        slots = IdxSet(2^(inst.rr2.nslots ÷ 2) - 1)
        for i = 1:inst.rr2.nteams
            for j = i+1:inst.rr2.nteams
                push!(phasedcons, GAcon(slots, 1, 1, [(i, j), (j, i)], 0))
            end
        end
        rr2 = RR2(inst.rr2.nteams, inst.rr2.nslots, false)
        inst = Instance(rr2, vcat(constraints(inst), phasedcons))
    end

    cons = constraints(inst)
    hardCons = ishard.(cons)
    #lastfeas = [trues(lastfeaslength) for c = 1:length(cons)]
    pen = Int.([ishard(c) ? inithardpen : c.pen for c in cons])

    tso, state =
        initialize_search(inst.rr2, cons, pen, start, maxiter, tabulength, infeaslength)
    offsetbuf, schedbuf, difbuf = init_buffers(tso, state)
    starttime = time()

    tabu = deepcopy(state.tabu)
    add_tabu = Vector{Move}()
    #allow_infeas = false
    for phc = 1:maxphases
#        allow_infeas = !allow_infeas
        state.lastimprov = state.it
        @show state.lastimprov, maxiter, state.it
#        @show allow_infeas
        while state.lastimprov + maxiter >= state.it
            search_step!(
                tso,
                state,
                offsetbuf,
                schedbuf,
                difbuf,
                accept_infeas = false,
            )
            # logging
            print("it ", state.it)
            print(" hpen ", state.hpen, " spen ", state.spen)
            print(" optval ", state.optval, " lastimprov ", state.lastimprov)
            print(" time ", round(time() - starttime, digits = 3), "\n")
            if state.hpen == 0 && state.spen == state.optval
                println(
                    "new best feasible solution found with value ",
                    state.optval,
                )
                println(state.optsched)
                if state.spen == 0
                    return state.optsched, state.optval
                end
                tabu = deepcopy(state.tabu)
                add_tabu = Vector{Move}()
            end
        end
        if state.optval == typemax(Int) # no feasible solution found
            return state.optsched, typemax(Int)
        end
        map!(i -> i + state.it - state.lastimprov, values(tabu))
        state.tabu = deepcopy(tabu)
        state.sched .= state.optsched
        state.hpen, state.spen = 0, state.optval
        for mv in add_tabu
            state.tabu[mv] = state.it + tabulength
        end
        println("accepting infeasible solutions...")
        for k = 1:infeaslength
            println("spen, hpen =", state.spen, " ", state.hpen)
            push!(
                add_tabu,
                search_step!(
                    tso,
                    state,
                    offsetbuf,
                    schedbuf,
                    difbuf,
                    accept_infeas = true,
                ),
            )
        end
    end
    return state.optsched, state.optval
end

"""
    relaxed(inst::Instance)

Relaxes a given instance. Returns a copy of `inst` with all soft constraints
deleted and all hard constraints markd as soft wth a penalty of 1.
"""
function relaxed(inst::Instance)
    cons = Vector{Vector{Constraint}}()
    for field in (:constrCA, :constrBR, :constrGA, :constrFA, :constrSE)
        temp = Vector{Constraint}()
        for c in getfield(inst, field)
            if c.pen == 0
                push!(temp, @set c.pen = 1)
            end
        end
        push!(cons, temp)
    end
    return Instance(inst.rr2, cons...)
end

"""
    assign_games(
        sched::Matrix{Int},
        rr2::RR2,
        patternset::Vector{Int},
        gencons::Vector{Constraint},
    )

Solves the game assignment subproblem, minimizing the offset penalties of
`gencons`. The schedule `sched` is used as a start solution if
`use_start == true` and gets overriden by the optimal solution.
"""
function assign_games!(
    sched::Matrix{Int},
    rr2::RR2,
    patternset::Vector{Int},
    gencons::Vector{Constraint};
    timelimit = GRB_INFINITY,
    usestart = true,
)
    gam = game_alloc_model(rr2, patternset, gencons; feas_relax = true)
    x = gam[:x]
    if usestart
        @assert is_schedule(rr2, sched)
        for s = 1:size(sched, 2)
            for i = 1:size(sched, 1)
                if sched[i, s] > 0
                    set_start_value(x[i, sched[i, s], s], 1)
                end
            end
        end
    end
    #MOI.set(gam, MOI.RawParameter("OutputFlag"), 0)
    MOI.set(
        gam,
        Gurobi.CallbackFunction(),
        (cb_data, cb_where) -> gam_callback(gam, cb_data, cb_where, timelimit),
    )
    optimize!(gam)
    status = termination_status(gam)
    if status == MOI.OPTIMAL || status == MOI.INTERRUPTED
        parse_solution!(sched, value.(x), gam)
        return objective_value(gam)
    else
        return GRB_INFINITY
    end
end

"""
    gam_callback(timelimit, cb_data, cb_where)

Callback used to stop GAM if the time limit is exceeded and a feasible solution
was found
"""
function gam_callback(model, cb_data, cb_where, timelimit)
    if cb_where == GRB_CB_MIP
        time, obj = Ref{Cdouble}(), Ref{Cdouble}()
        GRBcbget(cb_data, cb_where, GRB_CB_RUNTIME, time)
        GRBcbget(cb_data, cb_where, GRB_CB_MIP_OBJBST, obj)
        if time[] > timelimit && obj[] < GRB_INFINITY
            GRBterminate(backend(model))
        end
    end
end


text:
import ForwardDiff
using ForwardDiff.DEFAULT_CHUNK_THRESHOLD
using Base.Test

# seed RNG, thus making result inaccuracies deterministic
# so we don't have to retune EPS for arbitrary inputs
srand(1)

const XLEN = DEFAULT_CHUNK_THRESHOLD + 1
const YLEN = div(DEFAULT_CHUNK_THRESHOLD, 2) + 1
const X, Y = rand(XLEN), rand(YLEN)
const CHUNK_SIZES = (1, div(DEFAULT_CHUNK_THRESHOLD, 3), div(DEFAULT_CHUNK_THRESHOLD, 2), DEFAULT_CHUNK_THRESHOLD, DEFAULT_CHUNK_THRESHOLD + 1)
const FINITEDIFF_ERROR = 3e-5


text:
#export magmaInit, magmaFinalize

# magma_init
function magmaInit()
	ccall((:magma_init, libmagma),Cint,())
end

# magma_finalize
function magmaFinalize()
	ccall((:magma_finalize, libmagma),Cint,())
end