system("lindo < 1.cmd");
Sub Command1_Click () ' Sample VB matrix generator for LINDO. Uses ' the LINDO executable for Windows to perform ' the optimization. Dim I, X, Y ' Let the user know we are about to start optimization Print "Begin optimization..." ' Eliminate any old work files On Error Resume Next Kill "C:\LINDO\SHELL\LNDIN.TXT" Kill "C:\LINDO\SHELL\LNDOUT.TXT" On Error GoTo 0 ' Open a LINDO Command file Open "C:\LINDO\SHELL\LNDIN.TXT" For Output As #1 ' Always a good idea to do a PAGE 0 ' first off in LINDO command files Print #1, "PAGE 0" ' Send the formulation to the command file Print #1, "MAX 20X+30Y" Print #1, "ST" Print #1, "X<50" Print #1, "Y<60" Print #1, "X+2Y<120" Print #1, "END" ' Suppress the standard solution report Print #1, "TERSE" ' Solve the model Print #1, "GO" ' Open a file for storing the solution Print #1, "DIVERT C:\LINDO\SHELL\LNDOUT.TXT" ' Send the solution to the output file Print #1, "CPRI /N P" ' Close output file Print #1, "RVRT" ' Quit LINDO Print #1, "QUIT" ' Close LINDO command file Close #1 ' Shell to LINDO, passing the name of the ' command file in the command line. The 2 ' means run LINDO minimized. I = Shell("C:\LINDO\LINDO -t""C:\LINDO\SHELL\LNDIN.TXT""", 2) ' We now need to wait until LINDO creates ' our input file On Error Resume Next Do Err = 0 ' Try to open the solution file printed by ' LINDO Open "C:\LINDO\SHELL\LNDOUT.TXT" For Input As #1 ' Break out of loop if successful If Err = 0 Then Exit Do ' Let other tasks run DoEvents Loop On Error GoTo 0 ' Read in the variable values Input #1, X, Y ' Close solution file Close #1 ' Print solution on screen Print "X and Y =", X, Y End Sub
c:\Lindow32.exe -t 1.txt
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question