Results 1 to 2 of 2

Thread: How to return a solution from a series of Multi Linear Inequality Equations

  1. #1

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    How to return a solution from a series of Multi Linear Inequality Equations

    First, go ahead and read:
    http://cgm.cs.mcgill.ca/~beezer/Publ...is-kaluzny.pdf

    Then check out the bas in my attached project.
    The form is just a front end to load data from formatted txt files,
    where, inside the zip, are 3 examples of such files, with corresponding txt files explaining more legibly what those equations are.
    {oops, just noticed...didn't include em. Well, their in the zip file now.}

    BTW, the .trt extension is an association on my pc to wordpad, since I don't like using notepad on txt files.

    This is NOT a finished project, just an illustration of how to program whats in that PDF.


    Any questions, just ask!


    -Lou

    BTW,
    As that PDF explains, this method only works to return Non-Negative solutions, if any exists.

    So, if all solutions to the input set of equations have negative values, this supposedly fails.

    Obviously, if ALL the values of all solutions are in negative space, if the values of the multipliers are multiplied by -ve 1, then the method will return a solution which, again multiplied by -ve 1, would be the solution of your original equations.

    The true delema occurs when all possible solution sets span both sides of zero.

    In that case, if you know the low limits of your variables, then translate them via : OldVar = NewVar + LowLim

    Adjust your equations, solve them, then retranslate back via: NewVar = OldVar - LowLim.




    Now, if you Don't know if any of your variables will result in a general solution if they are < 0, then if all of those variables were translated into OldVar = NewVar - NewVar2, then if its possible, the process would return NewVar & NewVar2, where both would be >= 0, which when retranslated back, would give you your solution to your original variable. {As you can see, if NewVar ended up < NewVar2, then your OldVar would indeed be negative, while the method would truly have returned only positive solutions}

    However, this is an expensive operation, in effect doubling the # of input variables into the method.

    Therefore:

    My next development will do the following.
    1. The Input Matrix will be dimensioned to allow the input variables room to split 1 time. So instead of the input matrix being dimmed to -1 + #Vars + NumEquations-NumEquations that explicitely set a variable to a value, the input matrix is dimmed to -1 + 2*#Vars + ...
    2. Instead of referencing the uBound of the input matrix, a counter will be used pointing to the effective ubound of the matrix. This counter will initially be set to the value -1 + #Vars + ..., since no variables have yet split.
    3. An Identity matrix will be used that, when multiplied by the solution matrix generated by the equation solver, will return the solution set of the original variables.
    4. The Counter will incriment by 1 every time an original variable is to be split.
    5. When a variable is split, Wherever it exists in the input matrix, that spot that is identified by the counter will be set to -1* the multiplier of the splitted variable. Also the identity matrix will be updated with a -1 value at the row of the split variable, and column = the counter's current value.
    6. A Boolean matrix will indicate which original variables have not split. This will be used to determine which original variables can still be split.

    Attached Files Attached Files

  2. #2

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    Re: How to return a solution from a series of Multi Linear Inequality Equations

    Finished my bullets as listed in my first post.
    I've now got the method returning both positive AND negative values, if a valid solution exists with negative values.

    As an example, I Passed the following thru my tweaked version:

    Given the following set of equations:

    F_19 ==-2*T+2*F_0+2*F_1+2*F_2+2*F_3+1*F_5+1*F_6+1*F_9
    F_11 ==-5*T+2*F_0+3*F_1+2*F_2+3*F_3+2*F_5+2*F_6+1*F_9+1*F_4+1*F_8+1*F_10
    F_20 ==-4*T+4*F_0+4*F_1+2*F_2+3*F_3+2*F_5+2*F_6+2*F_4+1*F_8+1*F_10-1*F_18
    F_16 ==8*T-5*F_0-4*F_1-3*F_2-3*F_3-2*F_5-2*F_6-1*F_9-2*F_4-1*F_8-1*F_10-1*F_7
    F_21 ==-4*T+4*F_0+2*F_1+2*F_2+1*F_3+1*F_5+1*F_6+1*F_9+2*F_4+1*F_8+1*F_10+2*F_7-1*F_17
    F_15 ==10*T-4*F_0-4*F_1-2*F_2-3*F_3-2*F_5-2*F_6-1*F_9-2*F_4-2*F_8-2*F_10-2*F_7-1*F_12
    F_14 ==10*T-4*F_0-4*F_1-4*F_2-4*F_3-3*F_5-3*F_6-2*F_9-2*F_4-1*F_8-1*F_10-1*F_13
    T=381
    F_0=-24

    Required Limits:
    -24<=F_0<=102
    -123<=F_1<=-4 *F_1 thru F_3 are required to be in the -ve zone
    -123<=F_2<=-5
    -123<=F_3<=-6
    -123<=F_5<=597
    -123<=F_6<=597
    -123<=F_9<=597
    -123<=F_4<=597
    -123<=F_8<=597
    -123<=F_10<=597
    -123<=F_18<=597
    -123<=F_7<=597
    -123<=F_17<=597
    -123<=F_12<=597
    -123<=F_13<=597

    My New Method now returns the following valid answers for F_0 thru F_18:

    T = 381
    F_0 = -24
    F_1 = -4
    F_2 = -5
    F_3 = -6
    F_5 = 511
    F_6 = 0
    F_9 = 206
    F_4 = 597
    F_8 = 45
    F_10 = 0
    F_18 = 0
    F_7 = 153
    F_17 = 21
    F_12 = 535
    F_13 = 185

    Now, just to illustrate that these values work, Look at the following 2 attachements.
    They are screenshots of an equation generator, {which instigated my investigation into this inequality solution generator}.

    In the B4, you will see that, with all the Variables in the top row set to their minimal allowed values, that the values of the equations as listed in the left column are all out of range, either too high or too low. {They're not white at all!}

    In the after, after setting the values of the variables in the top row to that which my solver suggested, you will see that the values in the left column now are in the required range. {They are definitely all white!}


    BTW, I've also attached the new improved project, if anyone ever needs to see what I've done.

    Now, for my next development progression, I think I'm going to optimize my matrix processing, add a key matrix for nonzero rows, and an equivalent key matrix to let me iterate thru only the nonzero columns of each row. It speeds things up enormously.


    -Lou
    Attached Images Attached Images   
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width