Example of command script file usage in lingo

Source: Internet
Author: User

We sometimes encounter heavy, repetitive work when using lingo, manual operation is obviously time consuming, and the @for function in lingo can only do some simple loops, which requires us to apply the script file to simplify these repetitive work. The English part below is an example from the Official Handbook, which summarizes the 2 points I find useful:

1. script file type:. LTF However, the script file will not have a file highlighting, you can first use the normal editor and then copy it.

2. How to solve repetitive work: we usually store data in a relatively fixed format. For example, the number of waiters needed daily from Monday to Sunday, each of which is in a monday-sunday form. All we have to do is make smart calls, replace and store.

The example stores the data in the LDT format, so we can also call the Excel format (xlsx) file to read the required data. The replacement process is primarily used with an ALTER command, using the format:

ALTER ' new name ' old name '

The fields of all the old names will be replaced with new ones, so the program can be looped down.

It is also interesting to store data, the case is given in the text, and give each text corresponding to the name, we can actually use the @ole command to save all the results in a table, which is not difficult.

If you look at English feel trouble to see Xue Venus Teacher's textbook, in the fourth chapter lingo software and external file interface that chapter of the command script file that section. Very similar to the official.

Example Links:

Http://www.lindo.com/doc/online_help/lingo15_0/a_command_script_example.htm

Case content:

Once again, we'll make use of the the Staff scheduling model introduced on Using sets to illustrate the use of a command SCR Ipt. Suppose, instead of one hot dog stand, our operations has expanded and we now has three hot dog Stands:pluto Dogs, Mars Dogs, and Saturn Dogs. Our staffing requirements at the three sites is:

Thu

Site

Mon

Tue

Wed

Fri

Sat

Sun

Pluto

/td>

+

-

-

/

A

Mars

Ten

One

+

8

Saturn

8

+

+

/

+

Running Staffing models for all three sites are cumbersome (bulky) and prone to error. We would like to automate the process by constructing a script file, runs all three staffing models automatically. To does this, we construct the following script file:

! There are LINGO echo input to the Screenset Echoin 1! Suppresses the standard solution Reportset Terseo 1! Begins input of a new modelmodel:sets:  days/mon TUE WED THU FRI SAT sun/:   REQUIRED, START; Endsets DATA:  REQUIRED = @FILE (' PLUTO. LDT ');  @TEXT (' PLUTO. TXT ') = START; Enddata MIN = @SUM (Days (i): START (i)); @FOR (J): @SUM (Days (I) | I #LE # 5:start (@WRAP (j-i + 1, 7)))  >= REQUIRED (J)); @FOR (days: @GIN (START)); end! Solve Pluto Dogs modelgo! Alter model for Marsalter all ' PLUTO ' MARS '! Solve Mars modelgo! Alter model for Saturnalter all ' MARS ' SATURN '! Solve Saturn modelgo! Restore parametersset Terseo 0SET echoin 0

Command Script:dogs. LTF

We use the Set commands to set of LINGO ' s parameters. First, we set Echoin to 1, which causes LINGO to echo all command script input to the screen. This can is useful when you is trying to debug a script file. Next, we set Terseo to 1. This causes LINGO to go into terse output mode, which suppresses the default solution report each time we solve a model.

Next, we include the Model:command to put LINGO into MODEL input mode. It is important-remember the model:statement is a command. When LINGO encounters this command in a script file, it reads all subsequent text in the file as model text until it Encou Nters the END command. This model then becomes the current model in memory.

The key feature to note with our model are the data section:

DATA:  REQUIRED = @FILE (' PLUTO. LDT ');  @TEXT (' PLUTO. TXT ') = START; Enddata

We use the @FILE function to include the staffing requirements from a external FILE and we use the @TEXT function to send The values of the The START attribute to a file.

After the END statement, we had a GO command to solve the model for the Pluto stand. We then include a ALTER command to change all occurrences of ' PLUTO ' with ' MARS '. This command would change the data section to (changes in bold):

DATA:  REQUIRED = @FILE (' MARS. LDT ');  @TEXT (' MARS. TXT ') = START; Enddata

Assuming we have the staffing requirements for the Mars stand in the file Mars. The LDT, our model was then the ready to run again. However, this time it would solve for the START values of the Mars hot dog stand. We include commands to does the same for the Saturn location as well. Finally, we have both SET commands to restore the modified parameters.

You can run this command, script by issuing the file| Take Commands command in Windows versions of LINGO, or you can use the to command in other versions. Once the command script has been executed and you'll find the three solution Files:pluto. TXT, MARS. TXT, and SATURN. Txt. These files would contain the optimal values for the START attribute for each of the three locations.

Example of command script file usage in lingo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.