-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLP2.swift
More file actions
21 lines (19 loc) · 803 Bytes
/
LP2.swift
File metadata and controls
21 lines (19 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// LP2.swift
// AlgorithmsSwift
//
// Created by Michael Ho on 11/11/20.
//
class LP2 {
/**
Find the optimal output from the given main quation and its contraints.
- Parameter mainEquation: The main equation to find maximum/minimum values.
- Parameter constraints: Constraint equations to be considered when finding optimal solution.
- Parameter valueTarget: Determine the eqation should find maximum or minimum value.
*/
func findOptimumIntegerValue(mainEquation: SimplexEquation, constraints: [SimplexEquation], valueTarget: Target) -> Int {
let simplex = LP1.SimplexMethod(mainEquation: mainEquation, constraints: constraints, valueTarget: valueTarget)
simplex.iterate()
return Int((simplex.solution?.optimumValue)!)
}
}