Exemplo n.º 1
0
 public result Simplex(int cols, int rows, OptimisationDirection direction, bound[] rowbounds, bound[] colbounds, int[] ia, int[] ja, double[] ar, double[] coeff)
 {
     LPProblem p = new LPProblem();
     p.ObjectiveDirection = direction;
     p.AddCols(cols);
     p.AddRows(rows);
     for (int i = 0; i < rowbounds.Length; i++)
     {
         p.SetRowBounds(i + 1, rowbounds[i].BoundType, rowbounds[i].lower, rowbounds[i].upper);
     }
     for (int i = 0; i < colbounds.Length; i++)
     {
         p.SetColBounds(i + 1, colbounds[i].BoundType, colbounds[i].lower, colbounds[i].upper);
     }
     p.LoadMatrix(ia, ja, ar);
     //p.SetMatRow(1, new int[] {0, 1, 2 }, new double[] {0, 1, 1 });
     for (int i = 0; i < coeff.Length; i++)
     {
         p.SetObjCoef(i+1, coeff[i]);
     }
     p.SolveSimplex();
     Console.WriteLine("result = {0}, x1 = {1}, x2 = {2}", p.GetObjectiveValue(), p.GetColPrimal(1), p.GetColPrimal(2));
     //Console.In.ReadLine();
     result r = new result();
     r.ObjResult = p.GetObjectiveValue();
     r.Columns = new double[cols];
     for (int i = 0; i < cols; i++)
     {
         r.Columns[i] = p.GetColPrimal(i + 1);
     }
     return r;
 }
Exemplo n.º 2
0
 public s_trig(string name, Vector2 pos, ev_details[] ev, string util, GameObject[] bound, int gems, o_trigger.TRIGGER_TYPE trig, Vector2 trigSize, bool disable)
 {
     gemreq        = gems;
     this.name     = name;
     pos_x         = (int)pos.x;
     pos_y         = (int)pos.y;
     listofevents  = ev;
     this.trigSize = new s_save_vector(trigSize.x, trigSize.y);
     this.util     = util;
     boundaryobj   = new bound[bound.Length];
     for (int i = 0; i < bound.Length; i++)
     {
         boundaryobj[i] = new bound(bound[i].transform.position);
     }
     trigtye = trig;
     IsPermanentlyDisabled = disable;
 }
Exemplo n.º 3
0
 => Compute(expression, resultHolder, bound, bound);