diff_months: 0

Computer Programming Final Lab Assignment Solutions (Linear Programming, Machine Efficiency & First-Order Control Systems)

Flat 50% Off Order New Solution
Added on: 2026-09-12 11:50:57
Order Code:
Question Task Id: 0
  • Subject Code :

    ETCLZC164-SMCLZC164-CS-PYTHON

COMPUTER PROGRAMMING FINAL LAB ASSIGNMENT


Course Code: ETCLZC164 / SMCLZC164
Course Title: Computer Programming
Student Name:
Student ID: 202516SM010
Submission Date:


Introduction
This laboratory project is aimed at using the methods of Python programming in order to address the engineering-based problems that include optimisation, performance analysis and control systems. The assignment involves three stand-alone problems, namely, solving a linear programming problem with the help of optimisation methods, assessing machine efficiency with the aid of conditional logic and visualisation, and analysing a first-order control system with the help of a step response simulation.
All problems have their own parameters, which are based on the student ID, which makes them original, and no plagiarism can occur. Computations and visualisation are done with the help of Python libraries, including SciPy and Matplotlib.
Unique Parameters
The parameters required based on the student ID 202516SM010 are:
? x = 1 (last digit of ID)
? y = 0 (second last digit of ID)
These principles are applied to every problem.

Problem 1: Simplex Method of Linear Programming (5 Marks)

Problem Objective
In developing and solving a linear programming (LP) problem in Python, and finding the optimal solution, while commenting on the feasibility and optimality.
Mathematical Formulation

Objective Function
Minimize


Python Implementation

% Linear Programming using Simplex Method
% BITS ID: 202516SM010
% last digit - 0
% second last digit - 1
x = 1;
y = 0;
% Given,
% Minimize Z = (2 + 0.1x)X1 + (3+0.2y)X2
% Put x = 1, y = 0
% Z = (2 + 0.1(1))X1 + (3 + 0.2(0))X2
% Z = 2.1X1 + 3X2

f = [2.1 3];

% Constraint 1:
% (1 + 0x)X1 + (2 + 0.1y)X2 <= (20 + x + y)
% x = 1, y = 0
% (1 + 0)X1 + (2 + 0)X2 <= (20 + 1 + 0)
% X1 + 2X2 <= 21

% Constraint 2:
% (2 + 0.1y)X1 + (1 + 0.1y)X2 <= (18 + y)
% x = 1, y = 0
% (2 + 0)X1 + (1 + 0)X2 <= (18 + 0)
% 2X1 + X2 <= 18

A = [1 2;
2 1];

b = [21; 18];

% lower bound (X1 >= 0, X2 >=0)
lb = [0 0];

% From Linear Programming Problem
[X, Z] = linprog(f, A, b, [], [], lb);

% Results
disp('Optimal decision variables:')
disp(['X1 = ', num2str(X(1))])
disp(['X2 = ', num2str(X(2))])
disp('Optimal objective value:')
disp(['Z = ', num2str(Z)])


Results

? Optimal value of X1 = 0
? Optimal value of X2 = 0
? Minimum value of Z = 0


Figure 1:Graphical representation of the feasible region formed by the linear constraints in the simplex-based linear programming problem.

Feasibility and Optimality Discussion.

The solution found meets all the inequality conditions and non-negativity. The solution is feasible and optimal as the objective function attains its minimum value without any constraint being violated.

Problem 2: Machine Efficiency Analysis (5 Marks)
Problem Objective
To calculate machine efficiency using Python, determine whether the efficiency is acceptable, and visualise the result graphically.
Given Data

Python Implementation


import matplotlib.pyplot as plt

# From BITS ID 202516SM010
# Values from roll number
x = 1 # last Digit
y = 0 # Second Last Digit

# Power calculations
# Pin = 500 + 10x = 500 + 10(1) = 510 W
P_in = 500 + 10*x

# Pout = 350 + 8y = 350 + 8(0) = 350 W
P_out = 350 + 8*y

# Efficiency calculation
efficiency = (P_out / P_in) * 100
# Efficiency = Pout / Pin 100 = 350 / 510 100 ? 68.63%

# Results
print("Input Power (Pin):", P_in, "W")
print("Output Power (Pout):", P_out, "W")
print("Efficiency:", efficiency, "%")

# Efficiency Condition
if efficiency > 70:
print("Acceptable")
else:
print("Poor")

# Input Power vs Efficiency (single point)
plt.scatter(P_in, efficiency, color='red', s=100)
plt.xlabel("Input Power (W)")
plt.ylabel("Efficiency (%)")
plt.title("Input Power vs Efficiency")
plt.grid(True)
plt.show()
Results

? Calculated Efficiency = 68.62%
? Performance Status = Poor

Figure 2: Input power versus efficiency plot showing the calculated efficiency of 68.62% for the given machine parameters.
Conclusion

Since the calculated efficiency is smaller than 70%, the machine performance is considered poor.

Problem 3: First-Order Control System Analysis (5 Marks)

Problem Objective

To analyse the time response and stability of a first-order control system using Python simulation.
System Parameters

Transfer Function

Python Implementation

import control as ctrl
import matplotlib.pyplot as plt

# From BITS ID 202516SM010
# Values from roll number
x = 1
y = 0

# System parameters
K = 2 + 0.1*x # K = 2 + 0.1(1) = 2.1
? = 1 + 0.05*y # ? = 1 + 0.05(0) = 1

# Transfer function G(s) = K / (?*s + 1)
system = ctrl.tf([K], [?, 1])

# Step response
time, response = ctrl.step_response(system)

# Plot step response
plt.plot(time, response)
plt.xlabel("Time (seconds)")
plt.ylabel("Output")
plt.title("Step Response of First Order System")
plt.grid(True)
plt.show()

# Steady-state value
steady_state_value = response[-1]

# Rise time (10% to 90%)
t10 = time[next(i for i, v in enumerate(response) if v >= 0.1 * steady_state_value)]
t90 = time[next(i for i, v in enumerate(response) if v >= 0.9 * steady_state_value)]
rise_time = t90 - t10

# Display results
print("System Gain (K):", K)
print("Time Constant (?):", ?)
print("Rise Time:", rise_time, "seconds")
print("Steady-State Value:", steady_state_value)

# Stability comment
if ? > 0:
print("The system is stable.")
else:
print("The system is unstable.")
Results

? The step response becomes non-oscillating and gradually increases.
? The steady-state is 2.

Figure 3: Step response of the first-order control system illustrating stable behaviour and convergence to steady-state.

Stability Analysis

The transfer function pole is located on the negative real axis, and this causes the system to become stable. The steady-state solution is a solution obtained without oscillation and divergence.


Final Conclusion

The lab assignment has been able to demonstrate the use of Python programming to solve a linear optimisation problem, determine the efficiency of a machine, and analyse a control system. The unique parameters were used, based on the id of the student, and therefore it was original and done by adhering to the policy of academic integrity. The results make sure that there is good engineering interpretation and proper implementation.

References:

Jones, E., Oliphant, T., Peterson, P., et al. (2020). SciPy: Open source scientific tools for Python. SciPy.org. https://scipy.org

Kiusalaas, J. (2013). Numerical methods in engineering with Python 3. Cambridge University Press. https://doi.org/10.1017/CBO9781107449245

MathWorks. (2023). Linear programming (linprog) documentation. https://www.mathworks.com/help/optim/ug/linprog.html

Ogata, K. (2010). Modern control engineering (5th ed.). Prentice Hall.

Virtanen, P., Gommers, R., Oliphant, T. E., et al. (2020). SciPy 1.0: Fundamental algorithms for scientific computing in Python. Nature Methods, 17(3), 261272. https://doi.org/10.1038/s41592-019-0686-2

Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. OReilly Media.

  • Uploaded By : Priyan Sinha
  • Posted on : September 12th, 2026
  • Downloads : 0
  • Views : 0

Order New Solution

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Please Pay the Amount