/Big-M-Method

Big-M Method Implementation in Java

Primary LanguageJava

Big-M-Method

Big-M Method Implementation in Java

Suppose, we have:
Maximize z = x1 + 5x2
subject to:
3x1 + 4x2 ≤ 6
x1 + 3x2 ≥ 2
x1, x2 ≥ 0

If you want to solve this problem then, simply run the big_m_method.java code and enter values in console as same as below:

Choose Problem Type:
1) Maximization Problem
2) Minimization Problem
Enter chosen type: 1
Enter No. of variables: 2
Enter No. of constraints: 2
Enter coefficients of Objective Function:
Enter the value of x1: 1
Enter the value of x2: 5
Enter LHS coefficients of constraints(1) :
Enter the value of x1: 3
Enter the value of x2: 4
Choose Inequality option:
1) ≤
2) ≥
3) =
Enter chosen option: 1
Enter RHS coefficient of constraints(1) : 6
Enter LHS coefficients of constraints(2) :
Enter the value of x1: 1
Enter the value of x2: 3
Choose Inequality option:
1) ≤
2) ≥
3) =
Enter chosen option: 2
Enter RHS coefficient of constraints(2) : 2

************ Iteration - 1 ************
Incoming Variable is: x2
Outgoing Variable is: a1

************ Iteration - 2 ************
Incoming Variable is: s2
Outgoing Variable is: s1

Final table: [[1.2499999, 0.0, 0.75, 1.0, -1.0], [0.75, 1.0, 0.25, 0.0, 0.0]]

#Note: s1 is a slack variable, s2 is a surplus variable & a1 is an artificial variable.

*************** Basic Feasible Solution: *********************
The value of x1 is: 0
The value of x2 is: 1.5
The value of s1 is: 0
The value of s2 is: 2.4999998
The value of a1 is: 0
The value of Z_max is: 7.5

Process finished with exit code 0