Edit|Paste Special

windowsicon


Use the Paste Special command to insert the contents from the Windows clipboard into the active window at the cursor insertion point. This command can do much more than insert just plain text as done by the standard Paste command. Paste Special can be used to insert other objects and links to other objects. This is particularly useful for adding links to supporting data for your model. By inserting a link to your data sources, it is much easier to find and view them.

As an example, suppose we have the following transportation model:

! A 3 Warehouse, 4 Customer

Transportation Problem;

SETS:

 WAREHOUSE / WH1, WH2, WH3/: CAPACITY;

 CUSTOMER / C1, C2, C3, C4/: DEMAND;

 ROUTES( WAREHOUSE, CUSTOMER): COST, VOLUME;

ENDSETS

! The objective;

MIN = @SUM( ROUTES: COST * VOLUME);

 

! The demand constraints;

@FOR( CUSTOMER( J):

@SUM( WAREHOUSE( I): VOLUME( I, J)) >=

 DEMAND( J));

 

! The supply constraints;

@FOR( WAREHOUSE( I): [SUP]

@SUM( CUSTOMER( J): VOLUME( I, J)) <=

 CAPACITY( I));

 

! Here are the parameters;

DATA:

  CAPACITY = @OLE('D:\LNG\TRANLINKS.XLS');

  DEMAND = @OLE('D:\LNG\TRANLINKS.XLS');

  COST =  @OLE('D:\LNG\TRANLINKS.XLS');

  @OLE('D:\LNG\TRANLINKS.XLS') = VOLUME;

ENDDATA

As we can see from the data section, we are importing data from the Excel file TRANLINKS.XLS and writing the solution back out to the same file.

A nice feature would be to insert a link to the spreadsheet into our model file. This way, we could view the data and the solution without having to start Excel and load the spreadsheet. To do this, open Excel and load the spreadsheet as we have done here:

page113xp

For complete information on importing data from Excel, see Interfacing with Spreadsheets.

Now, select the range B2:F21 in the spreadsheet. Next, from Excel's Edit menu, choose the Copy command. Now, click on LINGO, place the cursor right before the data section, and give the Edit|Paste Special command. Click on the Paste Link button in the dialog box, so you see the following:

page114xp2

Finally, click the OK button and you should be able to see the spreadsheet contents in the LINGO model:

page115xp2

This link will be saved as part of your LINGO file. Therefore, whenever you open the model, the spreadsheet will be visible. Note that whenever you reopen the LINGO model, you may want to open the link, so the contents are updated automatically. You can do this by selecting the spreadsheet in the LINGO model, giving the Edit|Links command, and pressing the Open Links button in the dialog box.

As a final note, all embedded links and objects are ignored by LINGO's compiler. Thus, you are free to insert links and objects wherever you choose in a model.