How can I get solution vector from Linear Programming MT?

When solving a linear program using Linear Programming MT I get a very detail report printed on the screen or into an output file. However I just need to get the vector of solutions and the value of objective function at that solution point (and possibly other values). How do I get them so I can work with them as vectors? I need to run a Monte Carlo and will not be able to extract them manually each time from the output print out.

Sorry if I am missing something and thanks for any tips in advance.

2 Answers



0



accepted

Many of the Linear Programming (LPMT), use the GAUSS call keyword like this

call lpmtprt(lpmt(lp0,c0),c0);

The call keyword throws away the output values. The output values from LPMT are passed back as members of an lpOut structure. So to avoid printing the output report and to get the return values, you need to declare an lpOut structure and assign the output to it. So replace the previous line with this

//Declare 'out' to be an lpOut struct
struct lpOut out;

//Solve and send output values into the 'out' struct
out = lpmt(lp0,c0);

Now you can reference the objective function value and the solution vector as out.optimumValue and out.Solution. Note that if you want the printed output, you can keep the lpmtprt function where it is in the first call. Some notes from the manual on a few relevant output structure members is below.

/**      out.Solution   (N+M)x1 vector containing either (1) an optimal solution
**               to the original problem, or (2) the x values which minimize
**               the sum of the infeasiblities or (3), the last solution
**               found before it was determined that the problem is
**               unbounded or that the algorithm was unable to continue.  The
**               last M elements contain the values of the slack variables.
**
**      out.optimumValue   scalar, the value of the objective upon termination of
**               LPMT.  This may be the optimal value, the minimum sum
**               of the infeasiblities, or the largest value found before it
**               was determined that the problem was unbounded or that the
**               algorithm was unable to continue.
**
**
**     out.returncode  scalar, return code:
**
**                           0   An optimal solution was found
**                           1   The problem is unbounded
**                           2   The problem is infeasible
**                           5   Maximum number of iterations exceeded.
**                               Cycling may be occurring.
**                          13   Algorithm unable to find a suitable
**                               variable to enter the basis.  Either set
**                               eps1 or eps2 lower, or change
**                               rule[1] to another value.
**
**               If the return code is negative, then the program terminated
**               in Phase I.
**/

aptech

1,393


0



Thanks! This works.

SL

2

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy