Add a result class for LCPs - #18
Conversation
stengel
left a comment
There was a problem hiding this comment.
Question: how will you use the result class for an LCP?
At the moment the purpose seems to be for output only.
It should at some point be used to generate an equilibrium solution, which will come from the z output field.
When the LCP terminates, is the tableau still accessible? Because that will be needed for running the LCP solver backwards from an existing solution.
Finally, the value of z0 should only matter when there is ray termination. Will the values of z and w then be returned with their current values? And will there be information about the entering variable that leads to the infinite ray? (For this we should try to find instances of ray termination, also as test cases - in the bimatrix application this case should not arise and hence was not covered.)
Do you mean that this LCP result object should be used within
Right now tableau is only used within
When So, in case of success, we get this kind of object: which is printed as: And in case of failure: which is printed as:
Right now there are 2 LCPs that terminate on a secondary ray in |
Changes in detail:
A new
LcpResultclass is added to encapsulate the output of Lemke's algorithm. It contains:success: indicates whether a solution was found (True), or whether the algorithm terminated on a secondary ray (False).num_pivots: the number of pivots performed during the algorithm.basis: the set of basic variables at termination (e.g.{'w1', 'z2'}).z0: the final artificial variable value.z: the final values of thezvariables.w: the final values of thewvariables.ray_entering_variable: the entering variable that led to the secondary ray termination(
Noneif a solution is found).When
success=True,LcpResultstores the final LCP solution.When
success=False, it stores the last state reached before the algorithm terminated.A standalone function
result_from_tableau()creates a result object from a tableau, instead oftableau.createsol().And
LcpResult.__str__()creates the output string for the result object, instead ofoutsol().If$q \geq 0$ , $z = 0, w = q$ .
runlemke()now exits early without pivoting and returns the trivial solution: