Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Linear Programming Model Solver

A menu-driven C#/.NET 8 console application for solving and analysing Linear Programming (LP) and Integer Programming (IP) models.

The project was developed for **Linear Programming and supports multiple optimisation algorithms, sensitivity analysis, special-case detection, text-file input/output, and a nonlinear-programming bonus implementation.

Features

Linear Programming

  • Primal Simplex Algorithm
  • Revised Primal Simplex Algorithm
  • Canonical-form generation
  • Full tableau iteration output
  • Product Form and Price Out calculations
  • Maximisation models

Integer Programming

  • Branch and Bound Simplex
  • Branch and Bound Knapsack
  • Cutting Plane / Gomory Cut
  • Backtracking
  • Node generation and fathoming
  • Candidate and best-solution tracking

Sensitivity Analysis

  • Range and change of a selected non-basic variable coefficient
  • Range and change of a selected basic variable coefficient
  • Range and change of a constraint RHS value
  • Range and change of a coefficient in a non-basic variable column
  • Add a new activity
  • Add a new constraint
  • Shadow prices
  • Duality and duality-gap verification

Special Cases

  • Infeasible model detection
  • Unbounded model detection
  • Two-Phase Simplex
  • Artificial-variable handling
  • Dual Simplex re-optimisation

Nonlinear Programming Bonus

  • Golden Section Search
  • One-variable polynomial optimisation
  • Convexity / concavity checks using the second derivative
  • Generic polynomial evaluation using Horner's Method

Input / Output

  • Reads programming models from .txt files
  • Supports a dynamic number of variables and constraints
  • Supports <=, >=, and = relations
  • Supports variable restrictions such as +, -, urs, int, and bin
  • Exports results to a text file
  • Numerical results displayed to three decimal places

Technologies

  • C#
  • .NET 8
  • Visual Studio 2022
  • Object-Oriented Programming
  • Linear Programming
  • Integer Programming
  • Numerical Optimisation

Project Structure

LPR381Solver/
├── Algorithms/
├── Models/
├── Nonlinear/
├── Output/
├── Parsing/
├── SensitivityAnalysis/
├── SpecialCases/
├── TestFiles/
└── Program.cs

Input File Format

The first line specifies the optimisation direction and objective-function coefficients.

Each following line represents a constraint.

The final line specifies the variable restrictions.

Example:

max +60 +30 +20
+8 +6 +1 <=48
+4 +2 +1.5 <=20
+2 +1.5 +0.5 <=8
+ + +

This represents:

Maximise:
z = 60x1 + 30x2 + 20x3

Subject to:
8x1 + 6x2 + x3 <= 48
4x1 + 2x2 + 1.5x3 <= 20
2x1 + 1.5x2 + 0.5x3 <= 8

x1, x2, x3 >= 0

Running the Project

Visual Studio

  1. Clone the repository.
  2. Open the solution in Visual Studio 2022.
  3. Make sure the .NET 8 SDK is installed.
  4. Build the solution.
  5. Run the project.

Command Line

git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git
cd YOUR-REPOSITORY
dotnet restore
dotnet build
dotnet run

Main Menu

1. Load Programming Model from File
2. Display Loaded Model
3. Solve Model
4. Sensitivity Analysis
5. Export Results
6. Nonlinear Programming Bonus
7. Special Cases
0. Exit

Example Results

For the sample furniture LP:

x1 = 2.000
x2 = 0.000
x3 = 8.000

z = 280.000

For the Branch and Bound integer example:

x1 = 5.000
x2 = 0.000

z = 40.000

Error Handling

The application reports unsupported or invalid model/algorithm combinations instead of terminating unexpectedly.

Examples include:

  • Invalid input-file values
  • Unsupported variable restrictions for a selected algorithm
  • Infeasible programming models
  • Unbounded programming models
  • Incorrect algorithm selection for the loaded model

Learning Outcomes

This project demonstrates:

  • Implementation of optimisation algorithms from first principles
  • Matrix operations used by Revised Simplex
  • Recursive Branch and Bound
  • Gomory Cutting Planes
  • Dual Simplex
  • Sensitivity Analysis
  • Duality and Shadow Prices
  • Two-Phase Simplex
  • Numerical optimisation with Golden Section Search
  • File parsing and result exporting
  • Object-oriented C# application design

Academic Project

This repository contains an academic implementation developed as part of the LPR381 Linear Programming programming project.

Author

Christopher Wawa

About

C#/.NET 8 solver for Linear and Integer Programming featuring Simplex, Branch & Bound, Cutting Planes, sensitivity analysis, duality, special cases, and nonlinear optimization.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages