ie lab manual

27
Ex No 1: The Traveling Salesperson Problem Aim: To model the Travelling salesperson problem mathematically and solve using modeling package. Model Description :

Upload: elangomm3307

Post on 15-Oct-2014

48 views

Category:

Documents


4 download

TRANSCRIPT

Ex No 1: The Traveling Salesperson Problem

Aim: To model the Travelling salesperson problem mathematically and solve using modeling package.

Model Description :

Program :

MODEL: ! Traveling Salesman Problem for the cities of Atlanta, Chicago, Cincinnati, Houston, LA, Montreal; SETS: CITY / 1.. 3/: U; ! U( I) = sequence no. of city; LINK( CITY, CITY): DIST, ! The distance matrix; X; ! X( I, J) = 1 if we use link I, J; ENDSETS DATA: !Distance matrix, it need not be symmetric; DIST = 0 702 454 702 0 324 454 324 0 ; ENDDATA

!The model:Ref. Desrochers & Laporte, OR Letters, Feb. 91; N = @SIZE( CITY); MIN = @SUM( LINK: DIST * X); @FOR( CITY( K): ! It must be entered; @SUM( CITY( I)| I #NE# K: X( I, K)) = 1; ! It must be departed; @SUM( CITY( J)| J #NE# K: X( K, J)) = 1; ! Weak form of the subtour breaking constraints; ! These are not very powerful for large problems; @FOR( CITY( J)| J #GT# 1 #AND# J #NE# K: U( J) >= U( K) + X ( K, J) - ( N - 2) * ( 1 - X( K, J)) + ( N - 3) * X( J, K) ); ); ! Make the X's 0/1; @FOR( LINK: @BIN( X)); ! For the first and last stop we know...; @FOR( CITY( K)| K #GT# 1: U( K) <= N - 1 - ( N - 2) * X( 1, K); U( K) >= 1 + ( N - 2) * X( K, 1) );END

Solution :

Global optimal solution found at iteration: 0 Objective value: 1480.000

Variable Value Reduced Cost N 3.000000 0.000000 U( 1) 0.000000 0.000000 U( 2) 2.000000 0.000000 U( 3) 1.000000 0.000000 DIST( 1, 1) 0.000000 0.000000 DIST( 1, 2) 702.0000 0.000000 DIST( 1, 3) 454.0000 0.000000 DIST( 2, 1) 702.0000 0.000000 DIST( 2, 2) 0.000000 0.000000 DIST( 2, 3) 324.0000 0.000000 DIST( 3, 1) 454.0000 0.000000 DIST( 3, 2) 324.0000 0.000000 DIST( 3, 3) 0.000000 0.000000 X( 1, 1) 0.000000 0.000000 X( 1, 2) 0.000000 702.0000 X( 1, 3) 1.000000 454.0000 X( 2, 1) 1.000000 702.0000 X( 2, 2) 0.000000 0.000000 X( 2, 3) 0.000000 324.0000 X( 3, 1) 0.000000 454.0000 X( 3, 2) 1.000000 324.0000 X( 3, 3) 0.000000 0.000000

Results:

Ex No 2: Quadratic Assignment ProblemAim: To model a Quadratic Assignment Problem mathematically and solve using modeling package.Model :

Program :

MODEL:

! A quadratic assignment problem: Given transfers between flights and distance between gates, assign flights to gates to minimize total transfer distance;

SETS: FLIGHT/1..3/; ! There are three flights; GATE/1..4/; ! There are five gates; FXG( FLIGHT, GATE): X; !Flight-gate assignment; GXG( GATE, GATE): T; !Distance between gates; FXF( FLIGHT, FLIGHT): N; !Transfers btwn flights; ENDSETS

DATA: N = 0 30 5 ! No. transfers between flights; 20 0 0 30 40 0 ;

T = 0 5 10 14 ! distance between gates; 5 0 5 10 10 4 0 6 15 10 5 0 ; ENDDATA

SETS: ! Transfer between 2 flights must be required and related to 2 different gates. Warning: this set gets big fast.; TGTG( FLIGHT, GATE, FLIGHT, GATE)| &1 #LT# &3 #AND# (( N( &1, &3) #NE# 0) #AND# ( T( &2, &4) #NE# 0) #OR# ( N( &3, &1) #NE# 0) #AND# ( T( &4, &2) #NE# 0)): Y; ENDSETS

! Each flight, B, must be assigned to a gate; @FOR( FLIGHT( B): @SUM( GATE( J): X( B, J)) = 1);

! Each gate, J, can receive at most one flight; @FOR( GATE( J): @SUM( FLIGHT( B): X( B, J)) <= 1);

! Force Y(B,J,C,K)=1 if B assigned to J and C assigned to K; ! Assumes the T and N matrices are nonnegative; @FOR( TGTG( B, J, C, K): Y( B, J, C, K) >= X( B, J) + X( C, K) - 1);

! Min the sum of transfers * distance; MIN = @SUM( TGTG( B, J, C, K): Y( B, J, C, K) * ( N( B, C) * T( J, K) + N( C, B) * T( K, J)));

! Make the X's 0/1 (Y's will naturally be 0/1); @FOR( FXG: @BIN( X));

ENDSolution :

Global optimal solution found at iteration: 20 Objective value: 760.0000

Variable Value Reduced Cost X( 1, 1) 1.000000 600.0000 X( 1, 2) 0.000000 0.000000 X( 1, 3) 0.000000 0.000000 X( 1, 4) 0.000000 0.000000 X( 2, 1) 0.000000 0.000000 X( 2, 2) 1.000000 410.0000 X( 2, 3) 0.000000 0.000000 X( 2, 4) 0.000000 0.000000 X( 3, 1) 0.000000 0.000000 X( 3, 2) 0.000000 0.000000 X( 3, 3) 1.000000 510.0000 X( 3, 4) 0.000000 0.000000 T( 1, 1) 0.000000 0.000000 T( 1, 2) 5.000000 0.000000 T( 1, 3) 10.00000 0.000000 T( 1, 4) 14.00000 0.000000 T( 2, 1) 5.000000 0.000000 T( 2, 2) 0.000000 0.000000 T( 2, 3) 5.000000 0.000000 T( 2, 4) 10.00000 0.000000 T( 3, 1) 10.00000 0.000000 T( 3, 2) 4.000000 0.000000 T( 3, 3) 0.000000 0.000000 T( 3, 4) 6.000000 0.000000 T( 4, 1) 15.00000 0.000000 T( 4, 2) 10.00000 0.000000 T( 4, 3) 5.000000 0.000000 T( 4, 4) 0.000000 0.000000 N( 1, 1) 0.000000 0.000000 N( 1, 2) 30.00000 0.000000 N( 1, 3) 5.000000 0.000000 N( 2, 1) 20.00000 0.000000 N( 2, 2) 0.000000 0.000000 N( 2, 3) 0.000000 0.000000 N( 3, 1) 30.00000 0.000000 N( 3, 2) 40.00000 0.000000 N( 3, 3) 0.000000 0.000000 Y( 1, 1, 2, 2) 1.000000 0.000000 Y( 1, 1, 2, 3) 0.000000 500.0000 Y( 1, 1, 2, 4) 0.000000 720.0000 Y( 1, 1, 3, 2) 0.000000 175.0000 Y( 1, 1, 3, 3) 1.000000 0.000000 Y( 1, 1, 3, 4) 0.000000 520.0000 Y( 1, 2, 2, 1) 0.000000 250.0000 Y( 1, 2, 2, 3) 0.000000 230.0000

Y( 1, 2, 2, 4) 0.000000 500.0000 Y( 1, 2, 3, 1) 0.000000 175.0000 Y( 1, 2, 3, 3) 0.000000 145.0000 Y( 1, 2, 3, 4) 0.000000 350.0000 Y( 1, 3, 2, 1) 0.000000 500.0000 Y( 1, 3, 2, 2) 0.000000 220.0000 Y( 1, 3, 2, 4) 0.000000 280.0000 Y( 1, 3, 3, 1) 0.000000 350.0000 Y( 1, 3, 3, 2) 0.000000 170.0000 Y( 1, 3, 3, 4) 0.000000 180.0000 Y( 1, 4, 2, 1) 0.000000 730.0000 Y( 1, 4, 2, 2) 0.000000 500.0000 Y( 1, 4, 2, 3) 0.000000 270.0000 Y( 1, 4, 3, 1) 0.000000 495.0000 Y( 1, 4, 3, 2) 0.000000 350.0000 Y( 1, 4, 3, 3) 0.000000 205.0000 Y( 2, 1, 3, 2) 0.000000 200.0000 Y( 2, 1, 3, 3) 0.000000 400.0000 Y( 2, 1, 3, 4) 0.000000 600.0000 Y( 2, 2, 3, 1) 0.000000 200.0000 Y( 2, 2, 3, 3) 1.000000 0.000000 Y( 2, 2, 3, 4) 0.000000 400.0000 Y( 2, 3, 3, 1) 0.000000 400.0000 Y( 2, 3, 3, 2) 0.000000 200.0000 Y( 2, 3, 3, 4) 0.000000 200.0000 Y( 2, 4, 3, 1) 0.000000 560.0000 Y( 2, 4, 3, 2) 0.000000 400.0000 Y( 2, 4, 3, 3) 0.000000 240.0000

Results:

Ex no 3: Vehicle Routing Problems

Aim: To model the Vehicle Routing Problems mathematically and solve using modeling package.

Model:

MODEL:

! The Vehicle Routing Problem (VRP);

!************************************;! WARNING: Runtimes for this model ;! increase dramatically as the number;! of cities increase. Formulations ;! with more than a dozen cities ;! WILL NOT SOLVE in a reasonable ;! amount of time! ;!************************************;

SETS:

! Q(I) is the amount required at city I, U(I) is the accumulated delivers at city I ; CITY/1..8/: Q, U;

! DIST(I,J) is the distance from city I to city J X(I,J) is 0-1 variable: It is 1 if some vehicle travels from city I to J, 0 if none; CXC( CITY, CITY): DIST, X; ENDSETS

DATA: ! city 1 represent the common depo; Q = 0 6 3 7 7 18 4 5;

! distance from city I to city J is same from city J to city I distance from city I to the depot is 0, since the vehicle has to return to the depot;

DIST = ! To City; ! Chi Den Frsn Hous KC LA Oakl Anah From; 0 996 2162 1067 499 2054 2134 2050!Chicago; 0 0 1167 1019 596 1059 1227 1055!Denver; 0 1167 0 1747 1723 214 168 250!Fresno; 0 1019 1747 0 710 1538 1904 1528!Houston; 0 596 1723 710 0 1589 1827 1579!K. City; 0 1059 214 1538 1589 0 371 36!L. A.; 0 1227 168 1904 1827 371 0 407!Oakland; 0 1055 250 1528 1579 36 407 0;!Anaheim;

! VCAP is the capacity of a vehicle ; VCAP = 18; ENDDATA

! Minimize total travel distance; MIN = @SUM( CXC: DIST * X);

! For each city, except depot....; @FOR( CITY( K)| K #GT# 1:

! a vehicle does not traval inside itself,...; X( K, K) = 0;

! a vehicle must enter it,... ; @SUM( CITY( I)| I #NE# K #AND# ( I #EQ# 1 #OR# Q( I) + Q( K) #LE# VCAP): X( I, K)) = 1;

! a vehicle must leave it after service ; @SUM( CITY( J)| J #NE# K #AND# ( J #EQ# 1 #OR# Q( J) + Q( K) #LE# VCAP): X( K, J)) = 1;

! U( K) is at least amount needed at K but can't exceed capacity; @BND( Q( K), U( K), VCAP);

! If K follows I, then can bound U( K) - U( I); @FOR( CITY( I)| I #NE# K #AND# I #NE# 1: U( K) >= U( I) + Q( K) - VCAP + VCAP *

( X( K, I) + X( I, K)) - ( Q( K) + Q( I)) * X( K, I); );

! If K is 1st stop, then U( K) = Q( K); U( K) <= VCAP - ( VCAP - Q( K)) * X( 1, K);

! If K is not 1st stop...; U( K)>= Q( K)+ @SUM( CITY( I)| I #GT# 1: Q( I) * X( I, K)); );

! Make the X's binary; @FOR( CXC: @BIN( X));

! Minimum no. vehicles required, fractional and rounded; VEHCLF = @SUM( CITY( I)| I #GT# 1: Q( I))/ VCAP; VEHCLR = VEHCLF + 1.999 - @WRAP( VEHCLF - .001, 1);

! Must send enough vehicles out of depot; @SUM( CITY( J)| J #GT# 1: X( 1, J)) >= VEHCLR; END

Solution :

Global optimal solution found at iteration: 5 Objective value: 3230.000

Variable Value Reduced Cost VCAP 18.00000 0.000000 VEHCLF 0.8888889 0.000000 VEHCLR 1.000000 0.000000 Q( 1) 0.000000 0.000000 Q( 2) 6.000000 0.000000 Q( 3) 3.000000 0.000000 Q( 4) 7.000000 0.000000 U( 1) 0.000000 0.000000 U( 2) 6.000000 0.000000 U( 3) 9.000000 0.000000 U( 4) 7.000000 0.000000 DIST( 1, 1) 0.000000 0.000000 DIST( 1, 2) 996.0000 0.000000 DIST( 1, 3) 2162.000 0.000000 DIST( 1, 4) 1067.000 0.000000 DIST( 2, 1) 0.000000 0.000000 DIST( 2, 2) 0.000000 0.000000 DIST( 2, 3) 1167.000 0.000000 DIST( 2, 4) 1019.000 0.000000 DIST( 3, 1) 0.000000 0.000000 DIST( 3, 2) 1167.000 0.000000 DIST( 3, 3) 0.000000 0.000000 DIST( 3, 4) 1747.000 0.000000

DIST( 4, 1) 0.000000 0.000000 DIST( 4, 2) 1019.000 0.000000 DIST( 4, 3) 1747.000 0.000000 DIST( 4, 4) 0.000000 0.000000 X( 1, 1) 0.000000 0.000000 X( 1, 2) 1.000000 996.0000 X( 1, 3) 0.000000 2162.000 X( 1, 4) 1.000000 1067.000 X( 2, 1) 0.000000 0.000000 X( 2, 2) 0.000000 0.000000 X( 2, 3) 1.000000 1167.000 X( 2, 4) 0.000000 1019.000 X( 3, 1) 1.000000 0.000000 X( 3, 2) 0.000000 1167.000 X( 3, 3) 0.000000 0.000000 X( 3, 4) 0.000000 1747.000 X( 4, 1) 1.000000 0.000000 X( 4, 2) 0.000000 1019.000 X( 4, 3) 0.000000 1747.000 X( 4, 4) 0.000000 0.000000

Results:

Ex No 4: The Capacitated Plant Location Problem (CPL)

Aim: To model the Capacitated Plant Location Problem mathematically and solve using modeling package

Model Description:

Program :

MODEL: ! Capacitated Plant Location Problem; SETS: PLANTS / P1, P2, P3/: FCOST, CAP, OPEN; CUSTOMERS / C1, C2, C3, C4/ : DEM; ARCS( PLANTS, CUSTOMERS) : COST, VOL; ENDSETS

DATA: ! Fixed cost of opening at each origin; FCOST = 91, 70, 24; ! Capacities at each origin; CAP = 39, 35, 31; ! Demands at each destination;

DEM = 15, 17, 22, 12; ! The cost/unit shipment matrix; COST = 6, 2, 6, 7, 4, 9, 5, 3, 8, 8, 1, 5; ENDDATA

! The objective; [TTL_COST] MIN = @SUM( ARCS: COST * VOL) + @SUM( PLANTS: FCOST * OPEN);

! The demand constraints; @FOR( CUSTOMERS( J): [DEMAND] @SUM( PLANTS( I): VOL( I, J)) >= DEM( J) );

! The supply constraints; @FOR( PLANTS( I): [SUPPLY] @SUM( CUSTOMERS( J): VOL( I, J)) <= CAP( I) * OPEN( I) );

! Make OPEN binary(0/1); @FOR( PLANTS: @BIN( OPEN)); ENDSolution :

Global optimal solution found at iteration: 24 Objective value: 327.0000

Variable Value Reduced Cost FCOST( P1) 91.00000 0.000000 FCOST( P2) 70.00000 0.000000 FCOST( P3) 24.00000 0.000000 CAP( P1) 39.00000 0.000000 CAP( P2) 35.00000 0.000000 CAP( P3) 31.00000 0.000000 OPEN( P1) 1.000000 91.00000 OPEN( P2) 0.000000 -70.00000 OPEN( P3) 1.000000 -38.00000 DEM( C1) 15.00000 0.000000 DEM( C2) 17.00000 0.000000 DEM( C3) 22.00000 0.000000 DEM( C4) 12.00000 0.000000 COST( P1, C1) 6.000000 0.000000 COST( P1, C2) 2.000000 0.000000 COST( P1, C3) 6.000000 0.000000 COST( P1, C4) 7.000000 0.000000 COST( P2, C1) 4.000000 0.000000 COST( P2, C2) 9.000000 0.000000 COST( P2, C3) 5.000000 0.000000 COST( P2, C4) 3.000000 0.000000 COST( P3, C1) 8.000000 0.000000 COST( P3, C2) 8.000000 0.000000 COST( P3, C3) 1.000000 0.000000

COST( P3, C4) 5.000000 0.000000 VOL( P1, C1) 15.00000 0.000000 VOL( P1, C2) 17.00000 0.000000 VOL( P1, C3) 0.000000 3.000000 VOL( P1, C4) 3.000000 0.000000 VOL( P2, C1) 0.000000 2.000000 VOL( P2, C2) 0.000000 11.00000 VOL( P2, C3) 0.000000 6.000000 VOL( P2, C4) 0.000000 0.000000 VOL( P3, C1) 0.000000 4.000000 VOL( P3, C2) 0.000000 8.000000 VOL( P3, C3) 22.00000 0.000000 VOL( P3, C4) 9.000000 0.000000

Results:

Ex no : 5 one machine job selection

Aim: To model the Capacitated Plant Location Problem mathematically and solve using modeling package

MODEL: ! One machine job selection; SETS:

! There are six jobs each of which has a Due Date, Processing Time, Value, and a flag variable Y indicating if the job has been selected.; JOB/1..6/: ! Each job has a...; DD, ! Due date; PT, ! Processing time; VAL, ! Value if job is selected; Y; ! = 1 if job is selected, else 0; ENDSETS

DATA: VAL = 9 2 4 2 4 6; DD = 9 3 6 5 7 2; PT = 5 2 4 3 1 2; ENDDATA

! Maximize the total value of the jobs taken; MAX = TVAL; TVAL = @SUM( JOB: VAL * Y);

! For the jobs we do, we do in due date order; @FOR( JOB( J):

! Only jobs with earlier due dates can precede job J, and jobs must be completed by their due dates; @SUM( JOB( I)| DD( I) #LT# DD( J) #OR# ( DD( I) #EQ# DD( J) #AND# I #LE# J): PT( I) * Y( I)) <= DD( J);

! Make the Y's binary; @BIN( Y); );END

Solution :

Global optimal solution found at iteration: 0 Objective value: 19.00000

Variable Value Reduced Cost TVAL 19.00000 0.000000 DD( 1) 9.000000 0.000000 DD( 2) 3.000000 0.000000

DD( 3) 6.000000 0.000000 DD( 4) 5.000000 0.000000 DD( 5) 7.000000 0.000000 DD( 6) 2.000000 0.000000 PT( 1) 5.000000 0.000000 PT( 2) 2.000000 0.000000 PT( 3) 4.000000 0.000000 PT( 4) 3.000000 0.000000 PT( 5) 1.000000 0.000000 PT( 6) 2.000000 0.000000 VAL( 1) 9.000000 0.000000 VAL( 2) 2.000000 0.000000 VAL( 3) 4.000000 0.000000 VAL( 4) 2.000000 0.000000 VAL( 5) 4.000000 0.000000 VAL( 6) 6.000000 0.000000 Y( 1) 1.000000 -9.000000 Y( 2) 0.000000 -2.000000 Y( 3) 0.000000 -4.000000 Y( 4) 0.000000 -2.000000 Y( 5) 1.000000 -4.000000 Y( 6) 1.000000 -6.000000

Results:

Ex No 6: Development of random number generator

Aim: To generator random number under various distribution using excel

Steps:1. First generate random number based on the some distribution between 0 to

12. Find the mean of that number3. Count the fraction 0.25, 0.25 -0.50, 0.50-0.75, 0.75 -1 4. Interpret the results 5. End

Solution :

Results:

Ex No 7: Uniform Random varieties generation and testingAim : To generate the uniform random and perform the F-test on the random numbers

Steps :1. First generate random number for two varibles based on the some

distribution between 0 to 1 in column A and B 2. Plot the distribution using bar chart 3. Perform F-Test on the random numbers 4. Interpret the results 5. End

Solution :

Results :

Ex No 8: Linear regression equations

Aim : To find the liner regression equation between the given two data variation using excel.Steps :

1. Enter the given data in excel sheet2. Plot the relation between the given variables3. Draw the linear trend curve 4. Display the trend linear regression equation 5. Read the R2 value 6. Check the regression equation 7. End

Solution:

Results :

Ex No 9: Simulation of single server queuing system- A study

Exno:10 Flexible manufacturing system simulation – A study

Ex no: 11 P-chart

Ex no: 12 np-chart