internal void Solve()
        {
            if (constraints.Count == 0)
            {
                Status = Status.Optimal;
                return;
            }
            iterations = 0;

            Contract.Assert(y.Length > 0);

            var yCopy = new double[y.Length];

            do
            {
                if (iterations++ % refactorizationPeriod == 0 || factorization == null)
                {
                    var f = Factorization.CreateFactorization(new BMatrix(basis, A), U);
                    if (f != null)
                    {
                        factorization = f;
                    }
                    else
                    {
                        status = Status.FloatingPointError;
                        return;
                    }
                }
                bool leavingIsFound = false;
                FillCostsB(y);
                factorization.Solve_yBEquals_cB(y);


                Contract.Assume(0 <= yCopy.Length - ((IList <double>)y).Count);
                y.CopyTo(yCopy, 0);
                int startLookingForEnteringFrom = 0;
                do
                {
                    bool enteringHasToGrow;
                    var  entering = ChooseEnteringVariable(y, out enteringHasToGrow, startLookingForEnteringFrom);
                    if (entering == -1)
                    {
                        status = Status.Optimal;
                        return; //! returning from the middle of the loop in a good mood !
                    }

                    A.FillColumn(entering, y);
                    factorization.Solve_BdEqualsa(y);

                    var enteringT = BoundOnEnteringVar(entering, enteringHasToGrow);
                    //the value of the entering variable
                    var t       = enteringT;
                    var leaving = FindLeavingVariableAndT(y, ref t, enteringHasToGrow);
                    if (leaving == -1 && t == infinity)
                    {
                        status = Status.Unbounded;
                        //increasing the entering variable is always feasible, and the product costs*x grows infinitely
                        return; //again returning from the middle of the loop
                    }

                    if (leaving == -1 || Math.Abs(y[index[leaving]]) > etaEpsilon)
                    {
                        //check that the diagonal element in the eta-matrix is big enough
                        leavingIsFound = true;
                        FindNewXStarAndFactorization(leaving, entering, enteringHasToGrow ? t : -t, y, t < enteringT);
                        if (leaving >= artificialsStart)
                        {
                            Contract.Assume(artificialsStart >= 0);
                            ForgetVariable(leaving);
                        }
                    }
                    else
                    {
                        startLookingForEnteringFrom = entering + 1;
                        //restore y
                        yCopy.CopyTo(y, 0);
                    }
                } while (!leavingIsFound);
                //  if (StandardFactorization.calls >= 680) {
                //    ((StandardFactorization)factorization).CheckFactorization(new BMatrix(this.basis, A));
                // }
            } while (status != Status.Unbounded && status != Status.Optimal);
        }
    internal void Solve()
    {
      if (constraints.Count == 0)
      {
        Status = Status.Optimal;
        return;
      }
      iterations = 0;

      Contract.Assert(y.Length > 0);

      var yCopy = new double[y.Length];
      do
      {
        if (iterations++ % refactorizationPeriod == 0 || factorization == null)
        {
          var f = Factorization.CreateFactorization(new BMatrix(basis, A), U);
          if (f != null)
            factorization = f;
          else
          {
            status = Status.FloatingPointError;
            return;
          }
        }
        bool leavingIsFound = false;
        FillCostsB(y);
        factorization.Solve_yBEquals_cB(y);


        Contract.Assume(0 <= yCopy.Length - ((IList<double>) y).Count);
        y.CopyTo(yCopy, 0);
        int startLookingForEnteringFrom = 0;
        do
        {
          bool enteringHasToGrow;
          var entering = ChooseEnteringVariable(y, out enteringHasToGrow, startLookingForEnteringFrom);
          if (entering == -1)
          {
            status = Status.Optimal;
            return; //! returning from the middle of the loop in a good mood !
          }

          A.FillColumn(entering, y);
          factorization.Solve_BdEqualsa(y);

          var enteringT = BoundOnEnteringVar(entering, enteringHasToGrow);
          //the value of the entering variable
          var t = enteringT;
          var leaving = FindLeavingVariableAndT(y, ref t, enteringHasToGrow);
          if (leaving == -1 && t == infinity)
          {
            status = Status.Unbounded;
            //increasing the entering variable is always feasible, and the product costs*x grows infinitely
            return; //again returning from the middle of the loop
          }

          if (leaving == -1 || Math.Abs(y[index[leaving]]) > etaEpsilon)
          {
            //check that the diagonal element in the eta-matrix is big enough 
            leavingIsFound = true;
            FindNewXStarAndFactorization(leaving, entering, enteringHasToGrow ? t : -t, y, t < enteringT);
            if (leaving >= artificialsStart)
            {
              Contract.Assume(artificialsStart >= 0);
              ForgetVariable(leaving);
            }
          }
          else
          {
            startLookingForEnteringFrom = entering + 1;
            //restore y
            yCopy.CopyTo(y, 0);
          }
        } while (!leavingIsFound);
        //  if (StandardFactorization.calls >= 680) {
        //    ((StandardFactorization)factorization).CheckFactorization(new BMatrix(this.basis, A));
        // }
      } while (status != Status.Unbounded && status != Status.Optimal);
    }