Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            _solver = new ClSimplexSolver();

            // initialize the needed variables
            BuildVariables();

            // create the constraints
            try
            {
                BuildConstraints();
            }
            catch (ExClRequiredFailure rf)
            {
                Console.Error.WriteLine(rf.StackTrace);
            }
            catch (ExClInternalError ie)
            {
                Console.Error.WriteLine(ie.StackTrace);
            }

            // solve it
            try
            {
                _solver.Solve();
            }
            catch (ExClInternalError ie)
            {
                Console.Error.WriteLine(ie.StackTrace);
            }

            // print out the values
            Console.WriteLine("Variables: ");
            PrintVariables();
        }
Exemplo n.º 2
0
        public void Z3()
        {
            Stopwatch w = new Stopwatch();

            w.Restart();
            var solver = new ClSimplexSolver()
            {
                AutoSolve = false
            };

            Console.WriteLine("cons {0}ms", w.ElapsedMilliseconds);

            w.Restart();
            solver.AddConstraint(new ClVariable("x"), new ClVariable("y"), new ClVariable("z"), (x, y, z) =>
                                 x > 1 &&
                                 y == x + 1 &&
                                 y < 3 &&
                                 z == x + y * 3
                                 );
            Console.WriteLine("setup {0}ms", w.ElapsedMilliseconds);

            w.Restart();
            solver = solver.Solve();
            Console.WriteLine("solve {0}ms", w.ElapsedMilliseconds);

            w.Restart();
            Console.WriteLine("x " + ((ClVariable)solver.GetVariable("x")).Value);
            Console.WriteLine("y " + ((ClVariable)solver.GetVariable("y")).Value);
            Console.WriteLine("z " + ((ClVariable)solver.GetVariable("z")).Value);
            Console.WriteLine("read {0}ms", w.ElapsedMilliseconds);
        }
Exemplo n.º 3
0
 public static void Main(string[] args) 
 {
   _solver = new ClSimplexSolver();
   
   // initialize the needed variables
   BuildVariables();
   
   // create the constraints
   try 
   {
     BuildConstraints();
   } 
   catch (ExClRequiredFailure rf) 
   {
     Console.Error.WriteLine(rf.StackTrace);
   } 
   catch (ExClInternalError ie) 
   {
     Console.Error.WriteLine(ie.StackTrace);
   }
   
   // solve it
   try 
   {
     _solver.Solve();
   } 
   catch (ExClInternalError ie) 
   {
     Console.Error.WriteLine(ie.StackTrace);
   }
   
   // print out the values
   Console.WriteLine("Variables: ");
   PrintVariables();
 }
Exemplo n.º 4
0
        private void BuildStrongConstraints(ClSimplexSolver solver)
        {
            solver.AddConstraint(new ClLinearInequality(_updateRight, Cl.Operator.LessThanOrEqualTo, _newpostLeft, ClStrength.Strong));
            solver.AddConstraint(new ClLinearInequality(_newpostRight, Cl.Operator.LessThanOrEqualTo, _quitLeft, ClStrength.Strong));
            //_solver.AddConstraint(new ClLinearEquation(bottomRight_width, new ClLinearExpression(topRight_width), ClStrength.Strong));
            //_solver.AddConstraint(new ClLinearEquation(right_width, new ClLinearExpression(topRight_width), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_bottomRightBottom, new ClLinearExpression(_rightBottom), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_newpostHeight, new ClLinearExpression(_updateHeight), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_newpostWidth, new ClLinearExpression(_updateWidth), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_updateHeight, new ClLinearExpression(_quitHeight), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_quitWidth, new ClLinearExpression(_updateWidth), ClStrength.Strong));

            solver.AddConstraint(new ClLinearInequality(_lTitleBottom, Cl.Operator.LessThanOrEqualTo, _titleTop, ClStrength.Strong));
            solver.AddConstraint(new ClLinearInequality(_titleBottom, Cl.Operator.LessThanOrEqualTo, _lBodyTop, ClStrength.Strong));
            solver.AddConstraint(new ClLinearInequality(_lBodyBottom, Cl.Operator.LessThanOrEqualTo, _blogentryTop, ClStrength.Strong));

            solver.AddConstraint(new ClLinearEquation(_titleWidth, new ClLinearExpression(_blogentryWidth), ClStrength.Strong));

            solver.AddConstraint(new ClLinearInequality(_lRecentBottom, Cl.Operator.LessThanOrEqualTo, _articlesTop, ClStrength.Strong));

            solver.AddConstraint(new ClLinearInequality(_topRightBottom, Cl.Operator.LessThanOrEqualTo, _bottomRightTop, ClStrength.Strong));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.LessThanOrEqualTo, _rightLeft, ClStrength.Strong));
            //_solver.AddConstraint(new ClLinearEquation(left_height, new ClLinearExpression(right_height), ClStrength.Strong));
            //_solver.AddConstraint(new ClLinearEquation(fr_height, new ClLinearExpression(right_height), ClStrength.Strong));

            // alignment
            solver.AddConstraint(new ClLinearEquation(_lTitleLeft, new ClLinearExpression(_titleLeft), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_titleLeft, new ClLinearExpression(_blogentryLeft), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_lBodyLeft, new ClLinearExpression(_blogentryLeft), ClStrength.Strong));
            solver.AddConstraint(new ClLinearEquation(_lRecentLeft, new ClLinearExpression(_articlesLeft), ClStrength.Strong));
        }
Exemplo n.º 5
0
        public static bool Inconsistent3()
        {
            try
            {
                ClVariable      w      = new ClVariable("w");
                ClVariable      x      = new ClVariable("x");
                ClVariable      y      = new ClVariable("y");
                ClVariable      z      = new ClVariable("z");
                ClSimplexSolver solver = new ClSimplexSolver();

                solver
                .AddConstraint(new ClLinearInequality(w, Cl.GEQ, 10.0))
                .AddConstraint(new ClLinearInequality(x, Cl.GEQ, w))
                .AddConstraint(new ClLinearInequality(y, Cl.GEQ, x))
                .AddConstraint(new ClLinearInequality(z, Cl.GEQ, y))
                .AddConstraint(new ClLinearInequality(z, Cl.GEQ, 8.0))
                .AddConstraint(new ClLinearInequality(z, Cl.LEQ, 4.0));

                // no exception, we failed!
                return(false);
            }
            catch (ExClRequiredFailure)
            {
                // we want this exception to get thrown
                Console.WriteLine("-- got the exception");
                return(true);
            }
        }
Exemplo n.º 6
0
        public void TestLayout1()
        {
            var solver = new ClSimplexSolver();

            // initialize the needed variables
            BuildVariables();
            BuildConstraints(solver);

            solver.Solve();
        }
Exemplo n.º 7
0
        public void EndEdit_Throws()
        {
            var value = new ClVariable("value", 0);

            var solver = new ClSimplexSolver();

            solver.AddStay(value, ClStrength.Strong);

            solver.BeginEdit(value)
                  .SuggestValue(value, 25)
                  .EndEdit(); // <- Exception raised here
        }
Exemplo n.º 8
0
        public static bool JustStay1()
        {
            bool            okResult = true;
            ClVariable      x        = new ClVariable(5);
            ClVariable      y        = new ClVariable(10);
            ClSimplexSolver solver   = new ClSimplexSolver();

            solver.AddStay(x);
            solver.AddStay(y);
            okResult = okResult && Cl.Approx(x, 5);
            okResult = okResult && Cl.Approx(y, 10);

            Console.WriteLine("x == " + x.Value);
            Console.WriteLine("y == " + y.Value);

            return(okResult);
        }
Exemplo n.º 9
0
        public static bool Simple1()
        {
            bool            okResult = true;
            ClVariable      x        = new ClVariable(167);
            ClVariable      y        = new ClVariable(2);
            ClSimplexSolver solver   = new ClSimplexSolver();

            ClLinearEquation eq = new ClLinearEquation(x, new ClLinearExpression(y));

            solver.AddConstraint(eq);
            okResult = (x.Value == y.Value);

            Console.WriteLine("x == " + x.Value);
            Console.WriteLine("y == " + y.Value);

            return(okResult);
        }
Exemplo n.º 10
0
        public static bool AddDelete1()
        {
            bool            okResult = true;
            ClVariable      x        = new ClVariable("x");
            ClSimplexSolver solver   = new ClSimplexSolver();

            solver.AddConstraint(new ClLinearEquation(x, 100, ClStrength.Weak));

            ClLinearInequality c10 = new ClLinearInequality(x, Cl.LEQ, 10.0);
            ClLinearInequality c20 = new ClLinearInequality(x, Cl.LEQ, 20.0);

            solver
            .AddConstraint(c10)
            .AddConstraint(c20);

            okResult = okResult && Cl.Approx(x, 10.0);
            Console.WriteLine("x == " + x.Value);

            solver.RemoveConstraint(c10);
            okResult = okResult && Cl.Approx(x, 20.0);
            Console.WriteLine("x == " + x.Value);

            solver.RemoveConstraint(c20);
            okResult = okResult && Cl.Approx(x, 100.0);
            Console.WriteLine("x == " + x.Value);

            ClLinearInequality c10again = new ClLinearInequality(x, Cl.LEQ, 10.0);

            solver
            .AddConstraint(c10)
            .AddConstraint(c10again);

            okResult = okResult && Cl.Approx(x, 10.0);
            Console.WriteLine("x == " + x.Value);

            solver.RemoveConstraint(c10);
            okResult = okResult && Cl.Approx(x, 10.0);
            Console.WriteLine("x == " + x.Value);

            solver.RemoveConstraint(c10again);
            okResult = okResult && Cl.Approx(x, 100.0);
            Console.WriteLine("x == " + x.Value);

            return(okResult);
        }
Exemplo n.º 11
0
        protected void Init()
        {
            solver           = new ClSimplexSolver();
            solver.AutoSolve = false;

            var stayVariables = new LayoutAttribute[] {
                LayoutAttribute.Left,
                LayoutAttribute.Top
            };

            foreach (var attribute in stayVariables)
            {
                var variable = GetVariableFromViewAndAttribute(_rootView, attribute);
                variable.ChangeValue(0);

                _stayVariables.Add(attribute, variable);
                solver.AddStay(variable);
            }
        }
Exemplo n.º 12
0
        void AddEditVar(ClSimplexSolver solver, ClVariable variable)
        {
            if (!isStay.ContainsKey(variable.Name))
            {
                isStay.Add(variable.Name, 1);
                solver.AddStay(variable);
                solver.AddEditVar(variable, ClStrength.Strong);
            }
            else
            {
                var status = isStay[variable.Name];

                if (status == 0)
                {
                    solver.AddEditVar(variable);
                    isStay[variable.Name] = 1;
                }
            }
        }
Exemplo n.º 13
0
        public void EndEdit_NonRequiredVariable_SolvesCorrectly()
        {
            //Create a solver
            var solver = new ClSimplexSolver();
            var variable = new ClVariable(0f);

            //Add a stay, indicating this var should stay at it's current value if possible
            solver.AddStay(variable, ClStrength.Strong, 1);

            //Bug Fixing Note: The stay is strong, which overpowers the SuggestValue. If the stay is Medium or Weak then the SuggestValue takes hold and this test does *not* fail!
            //tl;dr: This bug only happens if the suggest value does nothing?

            const double EXPECTED_VALUE = 10.0;

            //Suggest a value for the variable in an edit context
            var editContext = solver.BeginEdit(variable);
            editContext.SuggestValue(variable, EXPECTED_VALUE);
            editContext.EndEdit();
        }
Exemplo n.º 14
0
        public static bool Inconsistent1()
        {
            try
            {
                ClVariable      x      = new ClVariable("x");
                ClSimplexSolver solver = new ClSimplexSolver();

                solver
                .AddConstraint(new ClLinearEquation(x, 10.0))
                .AddConstraint(new ClLinearEquation(x, 5.0));

                // no exception, we failed!
                return(false);
            }
            catch (ExClRequiredFailure)
            {
                // we want this exception to get thrown
                Console.WriteLine("-- got the exception");
                return(true);
            }
        }
Exemplo n.º 15
0
        public static bool Casso1()
        {
            bool            okResult = true;
            ClVariable      x        = new ClVariable("x");
            ClVariable      y        = new ClVariable("y");
            ClSimplexSolver solver   = new ClSimplexSolver();

            solver
            .AddConstraint(new ClLinearInequality(x, Cl.LEQ, y))
            .AddConstraint(new ClLinearEquation(y, Cl.Plus(x, 3.0)))
            .AddConstraint(new ClLinearEquation(x, 10.0, ClStrength.Weak))
            .AddConstraint(new ClLinearEquation(y, 10.0, ClStrength.Weak));

            okResult = okResult &&
                       (Cl.Approx(x, 10.0) && Cl.Approx(y, 13.0) ||
                        Cl.Approx(x, 7.0) && Cl.Approx(y, 10.0));

            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            return(okResult);
        }
Exemplo n.º 16
0
        public static bool AddDelete2()
        {
            bool            okResult = true;
            ClVariable      x        = new ClVariable("x");
            ClVariable      y        = new ClVariable("y");
            ClSimplexSolver solver   = new ClSimplexSolver();

            solver
            .AddConstraint(new ClLinearEquation(x, 100.0, ClStrength.Weak))
            .AddConstraint(new ClLinearEquation(y, 120.0, ClStrength.Strong));

            ClLinearInequality c10 = new ClLinearInequality(x, Cl.LEQ, 10.0);
            ClLinearInequality c20 = new ClLinearInequality(x, Cl.LEQ, 20.0);

            solver
            .AddConstraint(c10)
            .AddConstraint(c20);
            okResult = okResult && Cl.Approx(x, 10.0) && Cl.Approx(y, 120.0);
            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            solver.RemoveConstraint(c10);
            okResult = okResult && Cl.Approx(x, 20.0) && Cl.Approx(y, 120.0);
            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            ClLinearEquation cxy = new ClLinearEquation(Cl.Times(2.0, x), y);

            solver.AddConstraint(cxy);
            okResult = okResult && Cl.Approx(x, 20.0) && Cl.Approx(y, 40.0);
            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            solver.RemoveConstraint(c20);
            okResult = okResult && Cl.Approx(x, 60.0) && Cl.Approx(y, 120.0);
            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            solver.RemoveConstraint(cxy);
            okResult = okResult && Cl.Approx(x, 100.0) && Cl.Approx(y, 120.0);
            Console.WriteLine("x == " + x.Value + ", y == " + y.Value);

            return(okResult);
        }
Exemplo n.º 17
0
        public AutoLayoutPanel() : base()
        {
            Controls         = new Hashtable();
            Constraints      = new ArrayList();
            ControlVariables = new Hashtable();
            solver           = new ClSimplexSolver();
            VarConstraints   = new Hashtable();

            // Register ourselves.
            FindClControlByUIElement(this);

            // Force our X/Y to be 0, 0
            solver.AddConstraint(new ClLinearEquation(
                                     FindClVariableByUIElementAndProperty(this, "X"),
                                     new ClLinearExpression(0.0),
                                     ClStrength.Required));

            solver.AddConstraint(new ClLinearEquation(
                                     FindClVariableByUIElementAndProperty(this, "Y"),
                                     new ClLinearExpression(0.0),
                                     ClStrength.Required));
        }
Exemplo n.º 18
0
 private void BuildStayConstraints(ClSimplexSolver solver)
 {
     solver.AddStay(_updateHeight);
     solver.AddStay(_updateWidth);
     solver.AddStay(_newpostHeight);
     solver.AddStay(_newpostWidth);
     solver.AddStay(_quitHeight);
     solver.AddStay(_quitWidth);
     solver.AddStay(_lTitleHeight);
     solver.AddStay(_lTitleWidth);
     solver.AddStay(_titleHeight);
     solver.AddStay(_titleWidth);
     solver.AddStay(_lBodyHeight);
     solver.AddStay(_lBodyWidth);
     solver.AddStay(_blogentryHeight);
     // let's keep blogentry.width in favor of other stay constraints!
     // remember we later specify title.width to be equal to blogentry.width
     solver.AddStay(_blogentryWidth, ClStrength.Strong);
     solver.AddStay(_lRecentHeight);
     solver.AddStay(_lRecentWidth);
     solver.AddStay(_articlesHeight);
     solver.AddStay(_articlesWidth);
 }
Exemplo n.º 19
0
        bool AddEditVar(ClSimplexSolver solver, ClVariable variable, int value)
        {
            if (!isStay.ContainsKey(variable.Name))
            {
                isStay.Add(variable.Name, 0);
                variable.ChangeValue(value);

                solver.AddStay(variable);
                return(false);
            }
            else
            {
                var status = isStay[variable.Name];
                if (status == 0)
                {
                    solver.AddEditVar(variable);
                    isStay[variable.Name] = 1;
                }

                BeginEdit();
                solver.SuggestValue(variable, value);
                return(true);
            }
        }
Exemplo n.º 20
0
        public static bool AddDel(int nCns, int nVars, int nResolves)
        {
            Timer  timer    = new Timer();
            double ineqProb = 0.12;
            int    maxVars  = 3;

            Console.WriteLine("starting timing test. nCns = " + nCns +
                              ", nVars = " + nVars + ", nResolves = " + nResolves);

            timer.Start();
            ClSimplexSolver solver = new ClSimplexSolver();

            ClVariable[] rgpclv = new ClVariable[nVars];
            for (int i = 0; i < nVars; i++)
            {
                rgpclv[i] = new ClVariable(i, "x");
                solver.AddStay(rgpclv[i]);
            }

            ClConstraint[] rgpcns = new ClConstraint[nCns];
            int            nvs    = 0;
            int            k;
            int            j;
            double         coeff;

            for (j = 0; j < nCns; j++)
            {
                // number of variables in this constraint
                nvs = RandomInRange(1, maxVars);
                ClLinearExpression expr = new ClLinearExpression(UniformRandomDiscretized() * 20.0 - 10.0);
                for (k = 0; k < nvs; k++)
                {
                    coeff = UniformRandomDiscretized() * 10 - 5;
                    int iclv = (int)(UniformRandomDiscretized() * nVars);
                    expr.AddExpression(Cl.Times(rgpclv[iclv], coeff));
                }
                if (UniformRandomDiscretized() < ineqProb)
                {
                    rgpcns[j] = new ClLinearInequality(expr);
                }
                else
                {
                    rgpcns[j] = new ClLinearEquation(expr);
                }
                if (Trace)
                {
                    TracePrint("Constraint " + j + " is " + rgpcns[j]);
                }
            }

            Console.WriteLine("done building data structures");
            Console.WriteLine("time = " + timer.ElapsedTime);
            timer.Start();
            int cExceptions = 0;

            for (j = 0; j < nCns; j++)
            {
                // add the constraint -- if it's incompatible, just ignore it
                try
                {
                    solver.AddConstraint(rgpcns[j]);
                }
                catch (ExClRequiredFailure)
                {
                    cExceptions++;
                    if (Trace)
                    {
                        TracePrint("got exception adding " + rgpcns[j]);
                    }

                    rgpcns[j] = null;
                }
            }
            Console.WriteLine("done adding constraints [" + cExceptions + " exceptions]");
            Console.WriteLine("time = " + timer.ElapsedTime + "\n");
            timer.Start();

            int e1Index = (int)(UniformRandomDiscretized() * nVars);
            int e2Index = (int)(UniformRandomDiscretized() * nVars);

            Console.WriteLine("indices " + e1Index + ", " + e2Index);

            ClEditConstraint edit1 = new ClEditConstraint(rgpclv[e1Index], ClStrength.Strong);
            ClEditConstraint edit2 = new ClEditConstraint(rgpclv[e2Index], ClStrength.Strong);

            solver
            .AddConstraint(edit1)
            .AddConstraint(edit2);

            Console.WriteLine("done creating edit constraints -- about to start resolves");
            Console.WriteLine("time = " + timer.ElapsedTime + "\n");
            timer.Start();

            for (int m = 0; m < nResolves; m++)
            {
                solver.Resolve(rgpclv[e1Index].Value * 1.001,
                               rgpclv[e2Index].Value * 1.001);
            }

            Console.WriteLine("done resolves -- now removing constraints");
            Console.WriteLine("time = " + timer.ElapsedTime + "\n");

            solver.RemoveConstraint(edit1);
            solver.RemoveConstraint(edit2);

            timer.Start();

            for (j = 0; j < nCns; j++)
            {
                if (rgpcns[j] != null)
                {
                    solver.RemoveConstraint(rgpcns[j]);
                }
            }

            Console.WriteLine("done removing constraints and AddDel timing test");
            Console.WriteLine("time = " + timer.ElapsedTime + "\n");

            timer.Start();

            return(true);
        }
Exemplo n.º 21
0
 private void BuildConstraints(ClSimplexSolver solver)
 {
     BuildStayConstraints(solver);
     BuildRequiredConstraints(solver);
     BuildStrongConstraints(solver);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Creates and configures simplex solver
 /// </summary>
 private void CreateSolver()
 {
     solver           = new ClSimplexSolver();
     solver.Name      = NamePrefix();
     solver.AutoSolve = false;
 }
Exemplo n.º 23
0
 public CassowaryLayout()
 {
     Solver = new ClSimplexSolver();
 }
Exemplo n.º 24
0
 public void Initialize()
 {
     _solver = new ClSimplexSolver();
 }
Exemplo n.º 25
0
        public static bool Multiedit()
        {
            try
            {
                bool okResult = true;

                ClVariable      x      = new ClVariable("x");
                ClVariable      y      = new ClVariable("y");
                ClVariable      w      = new ClVariable("w");
                ClVariable      h      = new ClVariable("h");
                ClSimplexSolver solver = new ClSimplexSolver();

                solver
                .AddStay(x)
                .AddStay(y)
                .AddStay(w)
                .AddStay(h);

                solver
                .AddEditVar(x)
                .AddEditVar(y)
                .BeginEdit();

                solver
                .SuggestValue(x, 10)
                .SuggestValue(y, 20)
                .Resolve();

                Console.WriteLine("x = " + x.Value + "; y = " + y.Value);
                Console.WriteLine("w = " + w.Value + "; h = " + h.Value);

                okResult = okResult &&
                           Cl.Approx(x, 10) && Cl.Approx(y, 20) &&
                           Cl.Approx(w, 0) && Cl.Approx(h, 0);

                solver
                .AddEditVar(w)
                .AddEditVar(h)
                .BeginEdit();

                solver
                .SuggestValue(w, 30)
                .SuggestValue(h, 40)
                .EndEdit();

                Console.WriteLine("x = " + x.Value + "; y = " + y.Value);
                Console.WriteLine("w = " + w.Value + "; h = " + h.Value);

                okResult = okResult &&
                           Cl.Approx(x, 10) && Cl.Approx(y, 20) &&
                           Cl.Approx(w, 30) && Cl.Approx(h, 40);

                solver
                .SuggestValue(x, 50)
                .SuggestValue(y, 60)
                .EndEdit();

                Console.WriteLine("x = " + x.Value + "; y = " + y.Value);
                Console.WriteLine("w = " + w.Value + "; h = " + h.Value);

                okResult = okResult &&
                           Cl.Approx(x, 50) && Cl.Approx(y, 60) &&
                           Cl.Approx(w, 30) && Cl.Approx(h, 40);

                return(okResult);
            }
            catch (ExClRequiredFailure)
            {
                // we want this exception to get thrown
                Console.WriteLine("-- got the exception");
                return(true);
            }
        }
Exemplo n.º 26
0
        private void BuildRequiredConstraints(ClSimplexSolver solver)
        {
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_bottomRightHeight), _bottomRightTop), new ClLinearExpression(_bottomRightBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_bottomRightWidth), _bottomRightLeft), new ClLinearExpression(_bottomRightRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_bottomRightTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_bottomRightBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_bottomRightLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_bottomRightRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_updateHeight), _updateTop), new ClLinearExpression(_updateBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_updateWidth), _updateLeft), new ClLinearExpression(_updateRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_updateBottom, Cl.Operator.LessThanOrEqualTo, _bottomRightHeight));
            solver.AddConstraint(new ClLinearInequality(_updateRight, Cl.Operator.LessThanOrEqualTo, _bottomRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_newpostHeight), _newpostTop), new ClLinearExpression(_newpostBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_newpostWidth), _newpostLeft), new ClLinearExpression(_newpostRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_newpostBottom, Cl.Operator.LessThanOrEqualTo, _bottomRightHeight));
            solver.AddConstraint(new ClLinearInequality(_newpostRight, Cl.Operator.LessThanOrEqualTo, _bottomRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_quitHeight), _quitTop), new ClLinearExpression(_quitBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_quitWidth), _quitLeft), new ClLinearExpression(_quitRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_quitBottom, Cl.Operator.LessThanOrEqualTo, _bottomRightHeight));
            solver.AddConstraint(new ClLinearInequality(_quitRight, Cl.Operator.LessThanOrEqualTo, _bottomRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_topRightHeight), _topRightTop), new ClLinearExpression(_topRightBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_topRightWidth), _topRightLeft), new ClLinearExpression(_topRightRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_topRightTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_topRightBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_topRightLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_topRightRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_topRightRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lTitleHeight), _lTitleTop), new ClLinearExpression(_lTitleBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lTitleWidth), _lTitleLeft), new ClLinearExpression(_lTitleRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lTitleBottom, Cl.Operator.LessThanOrEqualTo, _topRightHeight));
            solver.AddConstraint(new ClLinearInequality(_lTitleRight, Cl.Operator.LessThanOrEqualTo, _topRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_titleHeight), _titleTop), new ClLinearExpression(_titleBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_titleWidth), _titleLeft), new ClLinearExpression(_titleRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_titleBottom, Cl.Operator.LessThanOrEqualTo, _topRightHeight));
            solver.AddConstraint(new ClLinearInequality(_titleRight, Cl.Operator.LessThanOrEqualTo, _topRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lBodyHeight), _lBodyTop), new ClLinearExpression(_lBodyBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lBodyWidth), _lBodyLeft), new ClLinearExpression(_lBodyRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lBodyBottom, Cl.Operator.LessThanOrEqualTo, _topRightHeight));
            solver.AddConstraint(new ClLinearInequality(_lBodyRight, Cl.Operator.LessThanOrEqualTo, _topRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_blogentryHeight), _blogentryTop), new ClLinearExpression(_blogentryBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_blogentryWidth), _blogentryLeft), new ClLinearExpression(_blogentryRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_blogentryBottom, Cl.Operator.LessThanOrEqualTo, _topRightHeight));
            solver.AddConstraint(new ClLinearInequality(_blogentryRight, Cl.Operator.LessThanOrEqualTo, _topRightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_leftHeight), _leftTop), new ClLinearExpression(_leftBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_leftWidth), _leftLeft), new ClLinearExpression(_leftRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lRecentHeight), _lRecentTop), new ClLinearExpression(_lRecentBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_lRecentWidth), _lRecentLeft), new ClLinearExpression(_lRecentRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_lRecentBottom, Cl.Operator.LessThanOrEqualTo, _leftHeight));
            solver.AddConstraint(new ClLinearInequality(_lRecentRight, Cl.Operator.LessThanOrEqualTo, _leftWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_articlesHeight), _articlesTop), new ClLinearExpression(_articlesBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_articlesWidth), _articlesLeft), new ClLinearExpression(_articlesRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_articlesBottom, Cl.Operator.LessThanOrEqualTo, _leftHeight));
            solver.AddConstraint(new ClLinearInequality(_articlesRight, Cl.Operator.LessThanOrEqualTo, _leftWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_leftHeight), _leftTop), new ClLinearExpression(_leftBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_leftWidth), _leftLeft), new ClLinearExpression(_leftRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_rightHeight), _rightTop), new ClLinearExpression(_rightBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_rightWidth), _rightLeft), new ClLinearExpression(_rightRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_rightTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_rightBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_rightLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_rightRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_rightRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearInequality(_topRightBottom, Cl.Operator.LessThanOrEqualTo, _rightHeight));
            solver.AddConstraint(new ClLinearInequality(_topRightRight, Cl.Operator.LessThanOrEqualTo, _rightWidth));

            solver.AddConstraint(new ClLinearInequality(_bottomRightBottom, Cl.Operator.LessThanOrEqualTo, _rightHeight));
            solver.AddConstraint(new ClLinearInequality(_bottomRightRight, Cl.Operator.LessThanOrEqualTo, _rightWidth));

            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_frHeight), _frTop), new ClLinearExpression(_frBottom), ClStrength.Required));
            solver.AddConstraint(new ClLinearEquation(Cl.Plus(new ClLinearExpression(_frWidth), _frLeft), new ClLinearExpression(_frRight), ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_frTop, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_frBottom, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_frLeft, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_frRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));
            solver.AddConstraint(new ClLinearInequality(_frRight, Cl.Operator.GreaterThanOrEqualTo, 0, ClStrength.Required));

            solver.AddConstraint(new ClLinearInequality(_leftBottom, Cl.Operator.LessThanOrEqualTo, _frHeight));
            solver.AddConstraint(new ClLinearInequality(_leftRight, Cl.Operator.LessThanOrEqualTo, _frWidth));
            solver.AddConstraint(new ClLinearInequality(_rightBottom, Cl.Operator.LessThanOrEqualTo, _frHeight));
            solver.AddConstraint(new ClLinearInequality(_rightRight, Cl.Operator.LessThanOrEqualTo, _frWidth));
        }