Example #1
0
        public LPREntry getLPREntry()
        {
            List <double> values     = getValues();
            List <String> valueNames = getColumns();
            double        z          = values[0];

            values.RemoveAt(0);
            valueNames.RemoveAt(0);
            LPREntry ObjectiveFunction = new LPREntry(z, '=', valueNames, values);

            return(ObjectiveFunction);
        }
Example #2
0
        public ObjectiveFunctionDialog(LPREntry objectiveFunction)
        {
            columns.Add("Z");
            columns.Add("=");
            columns.AddRange(objectiveFunction.getColumns());
            //Format will be Z=X1+X2+X3....
            InitializeComponent();


            for (int i = 0; i < objectiveFunction.getColumns().Count; i++)
            {
                Control[] ctrls = tblMatrix.Controls.Find(objectiveFunction.getColumns()[i] + "-multiplier", true);
                if (ctrls == null)
                {
                    continue;
                }
                double val = objectiveFunction.getValue()[i];
                ctrls[0].Text = val.ToString();
            }
        }
        public ConstraintDialog(LPREntry constraint)
        {
            columns.AddRange(constraint.getColumns());
            columns.Add("comparison");
            columns.Add("result");
            //Format will be Z=X1+X2+X3....
            InitializeComponent();


            for (int i = 0; i < constraint.getColumns().Count; i++)
            {
                Control[] ctrls = tblMatrix.Controls.Find(constraint.getColumns()[i] + "-multiplier", true);
                if (ctrls == null)
                {
                    continue;
                }


                double val = constraint.getValue()[i];
                ctrls[0].Text = val.ToString();
            }
        }
        public LPREntry ToLPREntry()
        {
            List <double> values = new List <double>();
            double        result = new double();
            char          comp   = new char();

            foreach (Control ctrl in tblMatrix.Controls)
            {
                if (ctrl.Name.Contains("result"))
                {
                    result = double.Parse(ctrl.Text);

                    continue;
                }
                if (ctrl.Name.Contains("comparison"))
                {
                    comp = ctrl.Text[0];
                    continue;
                }
                if (ctrl.Name.Contains("-multiplier"))
                {
                    double val = double.Parse(ctrl.Text);
                    values.Add(val);
                }
            }

            List <String> valueNames = getColumns();



            valueNames.RemoveAt(valueNames.Count - 1);

            LPREntry constraintEntry = new LPREntry(result, comp, valueNames, values);

            return(constraintEntry);
        }
 public LPRCalculator()
 {
     listLPRConstraints = new List <LPREntry>();
     ObjectiveFunction  = new LPREntry();
     decisionVariable   = new List <DecisionVariable>();
 }
 public void setObjectiveFunction(LPREntry of)
 {
     ObjectiveFunction = of;
 }