public void ObjectiveFunction_Substitution_Successful( ObjectiveFunction objectiveFunction, Decomposition decomposition, ObjectiveFunction expected) { objectiveFunction.Substitution(decomposition); CollectionAssert.AreEqual(expected.ToArray(), objectiveFunction.ToArray()); }
public void SimplexTable_Solve_Successful( Decomposition decomposition, ObjectiveFunction objectiveFunction, Fraction expected) { var dut = new SimplexTable(decomposition, objectiveFunction, _logger).Calculate(); Assert.AreEqual(expected, dut); }
public void Matrix_DecompositionByCornerPoint_Success( Matrix matrix, int[] cornerPoint, Decomposition expected) { var dut = matrix.DecompositionByCornerPoint(cornerPoint); CollectionAssert.AreEqual(expected.BasicVariables, dut.BasicVariables); CollectionAssert.AreEqual(expected.FreeVariables, dut.FreeVariables); CollectionAssert.AreEqual(expected.Coefficients, dut.Coefficients); }
public SimplexTable(Decomposition decomposition, ObjectiveFunction objectiveFunction, ILogger logger = null, UserChoice userChoice = null, bool isDecimalFractions = false) { _decomposition = decomposition; _logger = logger; _userChoice = userChoice; _isDecimalFractions = isDecimalFractions; _shortObjectiveFunction = ConvertToShortObjectiveFunction(decomposition, objectiveFunction); }
public void Test1() { var dec = new Decomposition { BasicVariables = new[] {5, 6, 7}, FreeVariables = new[] {0, 1, 2, 3, 4}, Coefficients = new Fraction[,] {{-2, 4, 1, -1, 0, 3}, {4, -3, -1, 1, 1, 6}, {1, 4, 1, 0, 1, 15}} }; var objFunc = new ObjectiveFunction(new Fraction[] {-3, -5, -1, 0, -2, 24}); var dut = new SimplexTable(dec, objFunc, new Logger()); var artBasic = dut.ToArtificialBasic(); }
public void Decomposition_RowIndexOfBearingElementAtColumn_Successful( Decomposition decomposition, int column, int expected) { Assert.AreEqual(expected, decomposition.RowIndexOfBearingElementAtColumn(column)); }
public void SimplexTable_Solve_Unsolvable(Decomposition decomposition, ObjectiveFunction objectiveFunction) { Assert.Throws(typeof(Exception), () => new SimplexTable(decomposition, objectiveFunction, _logger).Calculate()); }
/// <summary> /// Выделение из полной целевой функции нужных коэффициентов по декомпозиции /// </summary> private static ObjectiveFunction ConvertToShortObjectiveFunction(Decomposition decomposition, ObjectiveFunction objectiveFunction) { var shortObjectiveFunction = new List<Fraction>(); for (var i = 0; i < objectiveFunction.Count(); i++) { if (decomposition.FreeVariables.Contains(i)) shortObjectiveFunction.Add(objectiveFunction[i]); } shortObjectiveFunction.Add(objectiveFunction.Last()); return new ObjectiveFunction(shortObjectiveFunction); }