Created
April 1, 2016 13:35
-
-
Save universal/7a24849ab2a3834f506846a3838a3671 to your computer and use it in GitHub Desktop.
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
******************************************************************************** | |
* Options: | |
* - linear: 0 -> solve quadratic dummy model | |
* - linear: not(0) -> solve linear model | |
* - funclib: yes -> include stodlib | |
* - funclib: not(yes) -> do not include | |
* | |
* Examples: | |
* ide options: | |
* --linear=0 --funclib=yes => slow | |
* --linear=1 --funclib=yes => fast | |
* --linear=0 --funclib=no => fast | |
* --linear=1 --funclib=no => fast | |
******************************************************************************** | |
scalars | |
linear /%linear%/ | |
; | |
$IF "%funclib%" == "yes" $FuncLibIn stolib stodclib | |
set i /1*25000/; | |
parameters | |
y(i) | |
; | |
y(i) = 25; | |
variables | |
x(i) | |
target | |
; | |
equations | |
def_x_square(i) | |
def_x_linear(i) | |
def_target | |
; | |
def_x_square(i).. | |
x(i)*x(i) =e= y(i); | |
def_x_linear(i).. | |
x(i) =e= y(i); | |
def_target.. | |
target =e= sum(i, x(i)); | |
model x_square /def_x_square,def_target/; | |
model x_linear /def_x_linear,def_target/; | |
x.l(i) = 1; | |
if(linear, | |
solve x_linear using nlp minizing target; | |
else | |
solve x_square using nlp minizing target; | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment