0% found this document useful (0 votes)
94 views41 pages

CCS357 LAB MANUAL

The document outlines the curriculum for the CCS357 Optimization Techniques Laboratory at Jeppiaar Educational Trust, detailing various optimization problems and methods using R programming and TORA software. It includes a bonafide certificate, an index of experiments, and specific aims, algorithms, and results for each experiment. The laboratory focuses on practical applications of optimization techniques relevant to artificial intelligence and machine learning.

Uploaded by

iamhharish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views41 pages

CCS357 LAB MANUAL

The document outlines the curriculum for the CCS357 Optimization Techniques Laboratory at Jeppiaar Educational Trust, detailing various optimization problems and methods using R programming and TORA software. It includes a bonafide certificate, an index of experiments, and specific aims, algorithms, and results for each experiment. The laboratory focuses on practical applications of optimization techniques relevant to artificial intelligence and machine learning.

Uploaded by

iamhharish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

JEPPIAAR EDUCATIONAL TRUST,

OLD MAHABALIPURAM ROAD, CHENNAI – 600 119.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CCS357 – Optimization Techniques Laboratory

B.E(HONOURS)- Artificial Intelligence and Machine


Learning

NAME : ……………………………………………..…………

REG.NO : ………………………………………….….…………

BRANCH : ……CSE………………………………..……………

SUBJECT CODE : ……CCS357…………………..……………………

SUBJECT TITLE : ……Optimization Techniques………..……


JEPPIAAR EDUCATIONAL TRUST,
OLD MAHABALIPURAM ROAD, CHENNAI – 600 119.

BONAFIDE CERTIFICATE

This is a certified Bonafide record work of _____________________________

with Reg. No: ____________________________________ Submitted for the Anna University

Practical Examination held on _____________________ in CCS357– Optimization

Techniques Laboratory during the year 2024 – 2025.

Signature of the HOD Signature of the


Lab- In charge

Submitted for the University Practical Examination held on ……………………….

Internal Examiner External Examiner


INDEX

EX DATE TITLE PAGE MARKS SIGN


NO NO.
.
1 Solving Simplex Maximization
Problems Using R Programming

2 Solving Simplex Minimization


Problems Using R Programming.

3 Solving Mixed Constraints


Problems – Big M & Two Phase
Method Using Tora.

4 Solving Transportation Problems


Using R.

5
Solving Assignment Problems Using
R.

6 Solving Optimization Problems


Using Lingo

7 Studying Primal-Dual Relationships


In Lp Using Tora.

8 Solving Lp Problems Using Dual


Simplex Method Using Tora

9 Sensitivity & Post Optimality


Analysis Using Lingo.

10 Solving Shortest Route Problems


Using Optimization Software

11 Solving Project Management


Problems Using Optimization
Software
EX DATE TITLE PAGE MARKS SIGN
NO NO.
.
12 Testing Random Numbers And
Random Variates For Their
Uniformity

13 Testing Random Numbers And


Random Variates For Their
Independence

14 Solving Single Server Queuing


Model Using Simulation Software
Package

15 Solving Multi Server Queuing Model


Using Simulation Software Package
Ex.No:1 SOLVING SIMPLEX MAXIMIZATION
PROBLEMS USING R PROGRAMMING

AIM :
To solve Simplex Maximization Problems using R programming.

ALGORITHM:
1. Set up the coefficients for the objective function.
2. Construct a matrix to represent the coefficients of the constraints.
3. Specify the direction of each constraint by creating a vector containing the
directions.
4. Define the values on the right-hand side of the constraints.
5. Use the lp function to solve the linear program.

PROGRAM:

obj_coef<-c(3,2)
const_coef<-matrix(c(2,1,1,1),ncol=2,byrow=True)
const_dir<-c("<=","<=")
rhs<-c(8,6)
result<-lp("max",obj_coef,const_coef,const_dir,rhs)
print(result$solution)
OUTPUT:

RESULT:
Thus a R program is developed to solve simplex maximization problems.
Ex.No:2 SOLVING SIMPLEX MINIMIZATION
PROBLEMS USING R PROGRAMMING.

AIM :
To solve Simplex Minimization Problems using R programming.

ALGORITHM:
1. Set up the coefficients for the objective function.
2. Construct a matrix to represent the coefficients of the constraints.
3. Specify the direction of each constraint by creating a vector containing the
directions.
4. Define the values on the right-hand side of the constraints.
5. Use the lp function to solve the linear program.

PROGRAM:
obj_coef<-c(2,3)
const_coef<-matrix(c(1,1,2,3),ncol=2,byrow=TRUE)
const_dir<-c("<=","<=")
rhs<-c(4,9)
result<-lp("min",-obj_coef,const_coef,const_dir,rhs)
print(result$solution)
OUTPUT:

RESULT:
Thus a R program is developed to solve simplex minimization problems.
Ex.No:3 SOLVING MIXED CONSTRAINTS PROBLEMS – BIG
M & TWO PHASE METHOD USING TORA.

AIM :
To solve mixed constraints problems – Big M & Two Phase method using
TORA.

PROCEDURE:
1. Define the linear programming problem, including the objective function
and constraints.
2. Introduce slack variables for mixed constraints, setting them with a large
positive value (M).
3. Phase one aims to find an initial feasible solution by minimizing the sum of
artificial variables. Phase two optimizes the original problem using the simplex
method.
4. Solve the original linear programming problem using the simplex method,
starting from the initial feasible solution obtained in phase one.
5. Extract the optimal solution, including decision variable values, and conduct
sensitivity analysis to assess solution robustness.
OUTPUT:

RESULT:
Thus mixed constraint problems – Big M & Two Phase method are solved
using TORA.
Ex.No:4 SOLVING TRANSPORTATION PROBLEMS USING R.

AIM :
To solve Transportation Problems using R programming.

ALGORITHM:
1. Install and load the "transport" package.
2. Specify supply, demand, and transportation costs.
3. Utilize the transport function to find the optimal transportation plan.
4. Store the solution and associated information in a variable.
5. Print the optimized transportation plan and total cost.

PROGRAM:

install.packages("transport")
library(transport)
supply<-c(100,150,200)
demand<-c(120,180,150)
costs<-matrix(c(4,6,8,9,5,7,3,2,9),nrow=3,byrow=TRUE)
res<-transport(supply,demand,costs)
print(res)
OUTPUT:

RESULT:
Thus R Program for solving transportation problems is developed.
Ex.No:5 SOLVING ASSIGNMENT PROBLEMS USING R.

AIM :
To solve Assignment Problems using R programming.

ALGORITHM:
1. Install and load the "lpSolve" package for linear programming.
2. Define the cost matrix representing the assignment costs between agents and
tasks.
3. Create an LP model with the objective to minimize the total assignment cost.
Define constraints ensuring that each agent is assigned exactly one task, and
each task is assigned to exactly one agent.
4. Use the solve function to find the optimal solution to the LP model.
5. Print the assignment matrix showing which agent is assigned to which task,
and calculate the total cost of the assignment.

PROGRAM:
install.packages("lpSolve")
library(lpSolve)
cost_matrix <- matrix(c(
10, 7, 3, 5,
8, 6, 9, 4,
7, 9, 6, 2,
2, 4, 8, 7
), nrow = 4, byrow = TRUE)
num_agents <- nrow(cost_matrix)
num_tasks <- ncol(cost_matrix)
assignment_lp <- lp(direction = "min",
objective.in = as.vector(cost_matrix),
const.mat = rbind(matrix(1, nrow = num_agents),
t(matrix(1, nrow = num_tasks))),
const.dir = c("==", "=="),
const.rhs = c(1, 1),
all.bin = TRUE) # Binary variables
solution <- solve(assignment_lp)
assignment <- matrix(solution$solution, nrow = num_agents, ncol = num_tasks,
byrow = TRUE)
print("Assignment matrix:")
print(assignment)
total_cost <- sum(cost_matrix * assignment)
print(paste("Total cost:", total_cost))

OUTPUT:

RESULT:
Thus R Program for solving assignment problems is developed.
Ex.No:6 SOLVING OPTIMIZATION PROBLEMS USING
LINGO

AIM :
To solve Optimization Problems using LINGO.

ALGORITHM:
1. Define the objective function and constraints. The objective is to minimize
the expression given, subject to the constraints provided.
2. Declare decision variables and specify their binary nature using the @BIN
directive.
3. Set up the optimization model by specifying the objective function,
constraints, and variable types.
4. Use LINGO to solve the optimization problem and find the optimal solution.
5. Interpret the results, including the optimal values of decision variables and
the minimized objective function value, to derive actionable insights.

PROGRAM:
MIN = 22*x11 + 28*x12 + 30*x13 + 18*x14 + 18*x21 + 0*x22 + 27*x23 + 22*x24
+ 26*x31 + 20*x32 + 28*x33 + 28*x34 + 16*x41 + 22*x42 + 0*x43+ 14*x44 +
21*x51 + 0*x52 + 25*x53 + 28*x54;
x11 + x12 + x13 + x14 <= 1;
x21 + x23 + x24 <= 1;
x31 + x32 + x33 + x34 <= 1;
x41 + x42 + x44 <= 1;
x51 + x53 + x54 <= 1;
x11 + x21 + x31 + x41 + x51 = 1;
x12 + x32 + x42 = 1;
x13 + x23 + x33 + x53 = 1;
x14 + x24 + x34 + x44 + x54 = 1;
@BIN(x12);
@BIN(x13);
@BIN(x14);
@BIN(x21);
@BIN(x23);
@BIN(x24);
@BIN(x31);
@BIN(x32);
@BIN(x33);
@BIN(x34);
@BIN(x41);
@BIN(x42);
@BIN(x44);
@BIN(x51);
@BIN(x53);
@BIN(x54);
OUTPUT:
RESULT:
Thus an optimization problem is solved using LINGO.
Ex.No:7 STUDYING PRIMAL-DUAL RELATIONSHIPS IN LP
USING TORA.

AIM :
To study Primal Dual relationships in LP using TORA.

PROCEDURE:
1. Studying primal-dual relationships using the Temporally Ordered Routing
Algorithm (TORA) requires a different approach than traditional optimization
methods.
2. Recognize that TORA routing decisions can be viewed as solutions to an
optimization problem analogous to linear programming. Understand how
TORA optimizes routing decisions based on network conditions and
constraints.
3. Define LP optimization objectives relevant to TORA routing that align with
primal and dual objectives in LP problems. For instance, minimizing total
energy consumption, maximizing network throughput, or minimizing packet
transmission delay can be considered LP optimization.
4. Map the identified LP optimization objectives to a primal LP problem
formulation. Define decision variables, objective function, and constraints that
represent the routing decisions and network parameters optimized by TORA.
5. Derive the dual LP problem from the primal LP problem by introducing dual
variables associated with the primal problem's constraints. The dual problem
should offer insight into the trade-offs and relationships between different
optimization objectives in TORA routing.
6. Use LP solvers or optimization software to simulate TORA routing scenarios
as LP problems. Convert TORA routing decisions and network parameters into
LP problem formulations and input them into LP solvers for analysis.
7. Define LP performance metrics that capture the optimization objectives and
primal-dual relationships in TORA routing. Assess how well TORA routing
decisions align with the primal and dual optimization objectives based on LP
solver outputs.
8. Analyze the LP simulation results to understand how TORA routing
decisions relate to the primal and dual LP objectives. Investigate how changes
in network conditions or optimization parameters impact the primal and dual
solutions derived from LP simulations.
9. Draw conclusions based on the analysis of primal-dual relationships in
TORA routing as LP problems. Identify trade-offs, synergies, or conflicts
between different optimization objectives and assess the effectiveness of
TORA in achieving optimal or near-optimal solutions.
10. Iterate on the study by refining LP simulation parameters, adjusting
optimization objectives, or exploring alternative LP formulations.Continuously
refine your understanding of primal-dual relationships in TORA routing as LP
problems to deepen insights into network optimization.

RESULT:
Thus primal dual relationships in LP is studied using TORA.
Ex.No:8 SOLVING LP PROBLEMS USING DUAL SIMPLEX
METHOD USING TORA

AIM :
To solve LP Problems using Dual Simplex method using TORA.

PROCEDURE:
1. Define the LP problem, including the objective function and constraints.
2. Input the LP problem into TORA.
3. Choose the Dual Simplex Method in TORA.
4. Let TORA execute the Dual Simplex Method.
5. Review TORA's output for the optimal solution and analysis.

OUTPUT:
RESULT:
Thus LP Problems are solved using Dual Simplex Method in TORA.
Ex.No:9 SENSITIVITY & POST OPTIMALITY ANALYSIS
USING LINGO.

AIM :
To study sensitivity and post optimality analysis using LINGO.

PROCEDURE:
1. Sensitivity Analysis:
• Modify the coefficients of the objective function to observe how changes in
these coefficients affect the optimal objective value. You can increase or decrease the
coefficients to see if the optimal solution remains unchanged or if there's a change in
the objective value.
•Change the RHS values of the constraints to understand how variations in
resource availability or demand affect the optimal solution. Increase or decrease the
RHS values within feasible ranges and observe the impact on the optimal solution.
•LINGO provides shadow prices (dual values) associated with each constraint
in the LP model. Analyze the shadow prices to understand the impact of relaxing or
tightening constraints on the optimal solution. Positive shadow prices indicate that
increasing the RHS values of the corresponding constraints will lead to an increase in
the objective value, and vice versa.
•Determine the allowable increase and decrease in objective function
coefficients or RHS values before the optimal solution changes. This helps identify
the range within which the optimal solution remains unchanged.

2. Post-Optimality Analysis:

• Analyze the reduced costs associated with decision variables to identify


variables that are candidates for additional investment or reduction. Negative reduced
costs indicate that increasing the variable's value could improve the objective value.
•LINGO generates sensitivity reports that provide detailed information about
the sensitivity of the optimal solution to changes in problem parameters. Review
these reports to understand the impact of parameter variations on the optimal solution
and make informed decisions.
• Conduct feasibility analysis to ensure that the optimal solution remains
feasible even when parameters change. Verify that all constraints are satisfied within
acceptable tolerance levels.
•Explore different scenarios by systematically varying problem parameters and
observing changes in the optimal solution. This helps in understanding the robustness
of the solution and identifying potential risks or opportunities.

3. Interpretation and Decision-Making:

• Interpret the results of sensitivity and post-optimality analysis to gain insights


into the behavior of the LP model under different conditions.
•Use the analysis findings to make informed decisions regarding resource
allocation, capacity planning, pricing strategies, and other aspects of the optimization
problem.
•Communicate the results and recommendations to stakeholders effectively,
highlighting key insights and implications for decision-making.

RESULT:
Thus sensitivity and post optimality analysis is studied using LINGO.
Ex.No:10 SOLVING SHORTEST ROUTE PROBLEMS USING
OPTIMIZATION SOFTWARE

AIM :
To solve shortest route problems using optimization software-TORA.

PROCEDURE:
1. Define the shortest route problem.
2. Input the problem into TORA.
3. Select TORA's shortest path algorithm.
4. Let TORA find the shortest route.
5. Check TORA's output for the optimal route.

OUTPUT:
RESULT:
Thus shortest route problem is solved using TORA software.
Ex.No:11 SOLVING PROJECT MANAGEMENT PROBLEMS
USING OPTIMIZATION SOFTWARE

AIM :
To solve project management problems using optimization software – TORA.

PROCEDURE:
1. Define the project management problem, including tasks, durations, and
dependencies.
2. Input the project management problem into TORA.
3. Choose TORA's project scheduling algorithm.(CPM/PERT)
4. Allow TORA to optimize the project schedule.
5. Review TORA's output for the optimized project schedule.

OUTPUT :
RESULT:
Thus, project management problems are solved using TORA.
Ex.No:12 TESTING RANDOM NUMBERS AND RANDOM
VARIATES FOR THEIR UNIFORMITY

AIM :
To test random numbers and random variates for their uniformity.

ALGORITHM :
1. Generate a vector of 1000 random numbers using the uniform distribution.
2. Plot a histogram of the random numbers with 20 breaks using hist().
3. Perform a chi-square test on the binned data to test for uniformity using
chisq.test().
4. Perform a Kolmogorov-Smirnov test to compare the sample distribution with
the uniform distribution using ks.test().
5. Create a quantile-quantile plot to visually assess the goodness of fit between
the sample and theoretical uniform distribution using qqplot().

PROGRAM :
random_numbers = runif(1000)
hist(random_numbers,breaks=20,main-
"Histogram",xlab="Value",ylab="Frequency")
chi<-chisq.test(table(cut(random_numbers,breaks=20)))
test <- ks.test(random_numbers,"punif")
print(chi)
print(test)
qqplot(random_numbers, runif(1000), main = "Q-Q Plot", xlab = "Theoretical
Quantiles", ylab = "Sample Quantiles")
abline(0, 1)
OUTPUT :
RESULT:
Thus testing random numbers and random variates for their uniformity is
done using R programming.
Ex.No:13 TESTING RANDOM NUMBERS AND RANDOM
VARIATES FOR THEIR INDEPENDENCE

AIM :
To test random numbers and random variates for their independence.

ALGORITHM :
1. Generate 1000 random numbers from a uniform distribution.
2. Plot a histogram of the random numbers with 20 breaks.
3. Create a normal quantile-quantile plot to assess the normality of the
distribution.
4. Perform a Kolmogorov-Smirnov test to assess whether the data follows a
uniform distribution.
5. Perform a chi-square test to assess the goodness of fit between the observed
and expected frequencies.
6. Plot the autocorrelation function (ACF) of the random numbers.
7. Display the frequency table of the random numbers.

PROGRAM:
random_numbers <- runif(1000)
hist(random_numbers, breaks = 20, main = "Histogram of Random Numbers")
qqnorm(random_numbers)
qqline(random_numbers)
ks_test <- ks.test(random_numbers, "punif")
print(ks_test)
expected_counts <- rep(1000/20, 20)
expected_counts <- expected_counts / sum(expected_counts)
chi_square_test <- chisq.test(table(cut(random_numbers, breaks = 20)), p =
expected_counts)
print(chi_square_test)
acf(random_numbers)
frequency_table <- table(cut(random_numbers, breaks = 20))
print(frequency_table)

OUTPUT:
RESULT:
Thus, testing random numbers and random variates for their independence
is done using R programming.
Ex.No:14 SOLVING SINGLE SERVER QUEUING MODEL
USING SIMULATION SOFTWARE PACKAGE

AIM :
To solve single server queuing model using simulation software package.

PROCEDURE:
1. Problem Definition: Define the single server queuing model, including arrival
rates, service rates, and queue characteristics.
2. Simulation Setup: Input the queuing model parameters into simulation software
like Simul8 or Arena.
3. Simulation Execution: Run the simulation to model the queuing system's behavior
over time.
4. Result Analysis: Analyze the simulation output to understand queue lengths, wait
times, and system performance metrics.

OUTPUT:
RESULT:
Thus , single server queuing model is solved using simulation software
package.
Ex.No:15 SOLVING MULTI SERVER QUEUING MODEL
USING SIMULATION SOFTWARE PACKAGE

AIM :
To solve single server queuing model using simulation software package.

PROCEDURE:
1. Problem Definition: Define the multi-server queuing model, including parameters
such as arrival rates, service rates for each server, and the number of servers.
2. Simulation Setup: Input the queuing model parameters into simulation software like
Simul8 or Arena, specifying the number of servers and their respective service rates.
3. Simulation Execution: Run the simulation to model the behavior of the multi-server
queuing system over time. The simulation will track queue lengths, wait times, and
system performance metrics as customers move through the system.
4. Result Analysis: Analyze the simulation output to evaluate the efficiency of the
multi-server queuing system. This includes examining queue lengths, average wait
times, server utilization, and overall system performance. Adjustments to the number
of servers or their service rates can be made based on the simulation results to
optimize system performance.
OUTPUT:
RESULT:
Thus , multi server queuing model is solved using simulation software
package.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy