⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplexelement.cs

📁 线性规划的一种解法——两阶段单纯形算法
💻 CS
字号:
using System;
using System.Collections;

namespace NSLinearProgramming
{
    public class CSimplexColumnCollection : CStandardCollection<CSimplexColumn>
    {
        public CSimplexColumnCollection()
            : base()
        {
        }

        public CSimplexColumnCollection(int iCount)
            : base(iCount)
        {
        }
    }


    public class CSimplexRowCollection : CStandardCollection<CSimplexRow>
    {
        public CSimplexRowCollection()
            : base()
        {
        }

        public CSimplexRowCollection(int iCount)
            : base(iCount)
        {
        }
    }

    public class CSimplexColumn : CStandardElement
    {
        private double m_dValue;
        private double m_InJudge;
        private bool m_bIsBaseVariable = false;

        public CSimplexColumn()
        {
        }

        #region 属性
        public double Value
        {
            get { return this.m_dValue; }
            set { this.m_dValue = value; }
        }

        public double InJudge
        {
            get { return m_InJudge; }
            set { m_InJudge = value; }
        }

        public bool IsBaseVariable
        {
            get { return m_bIsBaseVariable; }
            set { m_bIsBaseVariable = value; }
        }
        #endregion

        #region IDisposable 成员

        public override void Dispose()
        {
            // TODO:  添加 CSimplexColumn.Dispose 实现
        }

        #endregion
    }

    public class CSimplexRow : CStandardElement
    {
        private double[] m_daConstraints;
        private double m_dResource;
        private double m_OutJudge;
        private CSimplexColumn m_Col = null;//行对应的基变量列

        public CSimplexRow(double[] daConstraints)
        {
            m_daConstraints = daConstraints;
        }

        public CSimplexRow(int iConstraintNumbers)
        {
            m_daConstraints = new double[iConstraintNumbers];
        }

        public void GetOutJudge(int iInVariablePosition)
        {
            this.OutJudge = double.PositiveInfinity;//正无穷

            if (this[iInVariablePosition] > 0)
            {
                double dθ = this.Resource / this[iInVariablePosition];

                //修改,2007-05-13,注释掉了下行
                //if (dθ > 0)
                    this.OutJudge = dθ;
            }
        }

        #region 属性
        public double Resource
        {
            get { return m_dResource; }
            set { m_dResource = value; }
        }

        public CSimplexColumn BaseVariableColumn
        {
            get { return m_Col; }
            set { m_Col = value; }
        }

        public double BaseVariableValue
        {
            get 
            {
                System.Diagnostics.Debug.Assert(m_Col != null);
                return m_Col.Value; 
            }
        }

        public double this[int index]
        {
            get
            {
                int iActualIndex = index;//下标从0开始

                System.Diagnostics.Debug.Assert(iActualIndex >= 0 && iActualIndex < m_daConstraints.Length);

                return m_daConstraints[iActualIndex];
            }
            set
            {
                int iActualIndex = index;//下标从0开始

                System.Diagnostics.Debug.Assert(iActualIndex >= 0 && iActualIndex < m_daConstraints.Length);

                m_daConstraints[iActualIndex] = value;
            }
        }

        public double OutJudge
        {
            get { return m_OutJudge; }
            set { m_OutJudge = value; }
        }

        #endregion


        #region IDisposable 成员

        public override void Dispose()
        {
            m_daConstraints = null;
        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -