public SymplexMatrix(ObjectiveFunction objectiveFunction, double[,] coefs, double[] basis, Sign[] signs) : base(coefs, basis, signs) { ObjectiveFunction = objectiveFunction; Variables = new Coef[Coefs.GetLength(0)][]; ValidateBasis(); IntroduceBalanceVariable(); IntroduceArtificialVariable(); }
private int GetIndexCoef(Coef coef) { for (int i = 0; i < SymplexMatrix.ObjectiveFunction.Coefs.Count; i++) { if (coef == SymplexMatrix.ObjectiveFunction.Coefs[i]) { return(i); } } return(-1); }
public Coef[] GetDualSolution() { Coef[] coefs = new Coef[SymplexMatrix.GetCountBalance()]; for (int i = SymplexMatrix.ObjectiveFunction.Coefs.Count - SymplexMatrix.GetCountArtificial() - SymplexMatrix.GetCountBalance(), j = 0; i < SymplexMatrix.GetCountBalance(); i++, j++) { coefs[j].Value = LastsymplexDifference[i, 0]; coefs[j].TypeCoef = TypeCoef.Balance; } return(coefs); }
public Coef[] AddCoefs(double[] arrayCoefs, TypeCoef typeCoefs) { Coef[] coefs = new Coef[arrayCoefs.Length]; for (int i = 0; i < coefs.Length; i++) { coefs[i] = new Coef() { TypeCoef = typeCoefs, Value = arrayCoefs[i], Row = i }; } return(coefs); }
public SymplexTable(SymplexMatrix symplexMatrix) { SymplexMatrix = symplexMatrix; Table = new double[symplexMatrix.Basis.Length, SymplexMatrix.Coefs.GetLength(1) + SymplexMatrix.GetCountBalance() + SymplexMatrix.GetCountArtificial() + 1]; CurrentBasis = new Coef[SymplexMatrix.Basis.Length]; InitTable(); }
private Coef[] ShapeOutputCoefs() { Coef[] coef = new Coef[CurrentBasis.Length]; for (int i = 0; i < CurrentBasis.Length; i++) { coef[i] = new Coef() { Row = GetIndexCoef(CurrentBasis[i]), TypeCoef = CurrentBasis[i].TypeCoef, Value = Table[i, 0] }; } return(coef); }
private void ChangeBasis(int row, Coef coef) { CurrentBasis[row] = coef; }