Пример #1
0
        public LPConstraint(LPPolynomial leftPolynomial, LPPolynomial rightPolynomial, LPOperatorType operatorType)
        {
            RightHand = new LPPolynomial(rightPolynomial);
            LeftHand = new LPPolynomial(leftPolynomial);

            OperatorType = operatorType;
        }
Пример #2
0
        public LPConstraint()
        {
            RightHand = new LPPolynomial();
            LeftHand = new LPPolynomial();

            OperatorType = LPOperatorType.Equals;
        }
Пример #3
0
        public LPModel()
        {
            _constraint = new List<LPConstraint>();

            GoalKind = null;
            Objective = new LPPolynomial();
            Name = "NewModel";
        }
Пример #4
0
        public static LPPolynomial JoinPolys(LPPolynomial poly1, LPPolynomial poly2)
        {
            var rLPoly = new LPPolynomial(poly1);

            foreach (var polyn in poly2.GetPoly)
            {
                rLPoly.AddNewVariable(polyn.Item1, polyn.Item2);
            }

            rLPoly.Constant += poly2.Constant;

            return rLPoly;
        }
Пример #5
0
        private static LPPolynomial ParsePolynomial(ParseTreeNode lpPolynomialNode)
        {
            var lpPoly = new LPPolynomial();

            switch (lpPolynomialNode.ChildNodes[0].ToString())
            {
                case "Monomial":
                    lpPoly = ParseMonomial(lpPolynomialNode.ChildNodes[0]);
                    break;
                case "lpNumber":
                    lpPoly = new LPPolynomial {Constant = ParseLPNumber(lpPolynomialNode.ChildNodes[0])};
                    break;
            }

            if (lpPolynomialNode.ChildNodes.Count == 3)
            {
                LPPolynomial oPoly = ParsePolynomial(lpPolynomialNode.ChildNodes[2]);
                lpPoly = LPPolynomial.JoinPolys(oPoly, lpPoly);
            }
            return lpPoly;
        }
Пример #6
0
        private static LPPolynomial ParseMonomial(ParseTreeNode node)
        {
            var lpPoly = new LPPolynomial();
            switch (node.ChildNodes.Count)
            {
                case 1:
                    lpPoly.AddNewVariable(node.ChildNodes[0].ToString().Replace("(variable)", "").Replace(" ", ""), 1f);
                    break;
                case 3:
                    double coefficient = 0;
                    switch (node.ChildNodes[0].ToString())
                    {
                        case "lpNumber":
                            coefficient = ParseLPNumber(node.ChildNodes[0]);
                            break;
                        case "number":
                            coefficient = ParseNumber(node.ChildNodes[0]);
                            break;
                        default:
                            throw new Exception("Invalid Model - Modeler Error At Monomial");
                    }

                    lpPoly.AddNewVariable(node.ChildNodes[2].ToString().Replace("(variable)", "").Replace(" ", ""),
                                          coefficient);
                    break;
            }

            return lpPoly;
        }
Пример #7
0
 public LPPolynomial(LPPolynomial poly)
 {
     _poly = new List<Tuple<string, double>>(poly.GetPoly);
     Constant = poly.Constant;
 }