# free variables

Free variables are variables that have no lower or upper bound. By default, variables don't have an upper bound, but they do have a lower bound of zero. So they can only take positive values. Free variables can also become negative until -infinite.

lp_solve supports free variables since a long time. Internally, these variables are split in a positive and negative part. So the result of using free variables is that the number of columns increases. However this is transparent to the user. The API call set_unbounded can be used to define a variable as free.

In the mps format, free variables can be specified in the BOUNDS section. See mps-format.
Example:

    NAME
    ROWS
     N  R0
     L  R1
     G  R2
     G  R3
     G  R4
    COLUMNS
        x1        R0        -1.000000000   R1        1.0000000000
        x1        R2        2.0000000000   R3        -1.000000000
        x2        R0        -2.000000000   R1        1.0000000000
        x2        R2        -1.000000000   R3        3.0000000000
        x3        R0        4.0000000000   R4        1.0000000000
        x4        R0        3.0000000000   R4        1.0000000000
    RHS
        RHS       R1        5.0000000000   R4        0.5000000000
    BOUNDS
     FR BND       x2
     UP BND       x3        10.000000000
     LO BND       x3        1.1000000000
     FR BND       x4
    ENDATA

The red lines specify that variables x2 and x4 are free variables.

In the lp format, free variables can be specified in the free section. See lp-format.
Example:

    max: x1 + 2x2 - 4x3 -3x4;
    x1 + x2 <= 5;
    2x1 - x2 >= 0;
    -x1 + 3x2 >= 0;
    x3 + x4 >= .5;
    x3 >= 1.1;
    x3 <= 10;

    free x2, x4;

    The red line specifies that variables x2 and x4 are free variables. The solution of this model is:

    Value of objective function: 5.73333

    Actual values of the variables:
    x1                        1.66667
    x2                        3.33333
    x3                            1.1
    x4                           -0.6

As can be seen, the value of x4 is -0.6, a negative value. If the variable would not be set as free, it would not be negative.