Download User's Manual

Transcript
LINDO CALLABLE LIBRARIES
255
// Define our two columns
char *cNameX = "X
";
char *cNameY = "Y
";
long lNonz = 3;
float fValX[] = { 20.f, 1.f, 1.f};
float fValY[] = { 30.f, 1.f, 2.f};
long lIroX[] = { 1, 2, 4};
long lIroY[] = { 1, 3, 4};
// Call APPCOL to send LINDO column X
APPCOL( &cNameX, &lNonz, fValX, lIroX, &lTruble);
// Call APPCOL to send LINDO column Y
APPCOL( &cNameY, &lNonz, fValY, lIroY, &lTruble);
// Call GO to optimize the model
long lLIMGO = 0, lISTAT;
GO( &lLIMGO, &lISTAT);
// Get the solution from LINDO
// Get the objective value
float fDual;
i = 1;
REPROW( &i, &m_fObjective, &fDual);
// Get the value of X
REPVAR( &i, &m_fX, &fDual);
// Get the value of Y
i = 2;
REPVAR( &i, &m_fY, &fDual);
// Post solution values in dialog box
UpdateData( FALSE);
// Shut LINDO down
LSEXIT();
// All done
return;
}
First off, in the above code, LINDO is initialized with the calls:
ILINDO();
INIT();
ILINDO performs one-time initialization for LINDO. It should be called once at the start of your code.
Next, the INIT command performs initialization for a new model. INIT should be called each time
your code begins input of a new model.
Next, a file called LINDO.OUT is open with the LUNOPN routine, and LINDO’s standard output is
redirected to this file via a call to CAPOUT:
char *cKfname = "LINDO.OUT";
long lUnit = 60, lFname = 9, lInOrOut = 0,
lNotFmt = 0, lLutrmi = 0, lLutrmo = 0;
LUNOPN( &lUnit, &lFname, &cKfname, &lInOrOut,
&lNotFmt, &lLutrmi, &lLutrmo);
// Now, tell LINDO to divert all standard
// output to this unit
CAPOUT( &lUnit);