cargo_OLE

1
! This model illustrates importing and exporting spreadsheet data in LINGO using the Object linking and Embedding (OLE) feature of the Windows OS ! The model is divided into three segments: sets, equations and data; ! CARGO LOADING PROBLEM, 3.4-15; SETS: CARGO/1 .. 4/:PROFIT, LOAD, VOLTON; COMP/1 .. 3/:WTCAP, VOLCAP; LINKS(CARGO, COMP):WGT; ENDSETS [Totprof] MAX=@SUM(LINKS(I,J):PROFIT(I)*WGT(I,J)); !The Objective Function; @FOR(CARGO(I):[cargo_avail]@SUM(COMP(J):WGT(I,J))<=LOAD(I)); @FOR(COMP(J):[comp_wt_cap]@SUM(CARGO(I):WGT(I,J))<=WTCAP(J)); @FOR(COMP(J):[comp_vol_cap]@SUM(CARGO(I):VOLTON(I)*WGT(I,J))<=VOLCAP(J)); @FOR(COMP(J):[comp_balance]@SUM(CARGO(I):WGT(I,J))/WTCAP(J)=RATIO); DATA: ! Get the name of the data attributes from an excel file; PROFIT = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet'); LOAD = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet'); VOLTON = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet'); WTCAP = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet'); VOLCAP = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet'); ! Send the optimal solution back to the excel file; @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet') = WGT; @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet') = Totprof; ENDDATA

description

cargo problem

Transcript of cargo_OLE

Page 1: cargo_OLE

! This model illustrates importing and exporting spreadsheet data in

LINGO

using the Object linking and Embedding (OLE) feature of the Windows OS

! The model is divided into three segments: sets, equations and data;

! CARGO LOADING PROBLEM, 3.4-15;

SETS:

CARGO/1 .. 4/:PROFIT, LOAD, VOLTON;

COMP/1 .. 3/:WTCAP, VOLCAP;

LINKS(CARGO, COMP):WGT;

ENDSETS

[Totprof] MAX=@SUM(LINKS(I,J):PROFIT(I)*WGT(I,J));

!The Objective Function;

@FOR(CARGO(I):[cargo_avail]@SUM(COMP(J):WGT(I,J))<=LOAD(I));

@FOR(COMP(J):[comp_wt_cap]@SUM(CARGO(I):WGT(I,J))<=WTCAP(J));

@FOR(COMP(J):[comp_vol_cap]@SUM(CARGO(I):VOLTON(I)*WGT(I,J))<=VOLCAP(J));

@FOR(COMP(J):[comp_balance]@SUM(CARGO(I):WGT(I,J))/WTCAP(J)=RATIO);

DATA:

! Get the name of the data attributes from an excel file;

PROFIT = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet');

LOAD = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet');

VOLTON = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet');

WTCAP = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet');

VOLCAP = @OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet');

! Send the optimal solution back to the excel file;

@OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet') = WGT;

@OLE( 'E:\Cargo_OLE\cargo_OLE_spreadsheet') = Totprof;

ENDDATA