internal override void InitializeRungeKuttaClasses() { bbampl = new BBAMPL(); dec = new DEC(); sol = new SOL(); dech = new DECH(); solh = new SOLH(); decc = new DECC(); solc = new SOLC(); dechc = new DECHC(); solhc = new SOLHC(); decb = new DECB(); solb = new SOLB(); decbc = new DECBC(); solbc = new SOLBC(); elmhes = new ELMHES(); //solout = new SOLOUTR(INTERN); contr5 = new CONTR5(CONRA5); decomr = new DECOMR(dec, decb, elmhes, dech, LINAL); decomc = new DECOMC(decc, decbc, dechc, LINAL); slvrar = new SLVRAR(sol, solb, solh, LINAL); slvrai = new SLVRAI(solc, solbc, solhc, LINAL); slvrad = new SLVRAD(sol, solc, solb, solbc, solh, solhc, LINAL); estrad = new ESTRAD(sol, solb, solh, LINAL); estrav = new ESTRAV(sol, solb, solh, LINAL); slvrod = new SLVROD(sol, solb, LINAL); slvseu = new SLVSEU(sol, solb, solh, LINAL); radcor = new RADCOR(decomr, decomc, slvrad, estrad, CONRA5, LINAL); radau5 = new RADAU5(radcor); //dr1_radau5 = new DR1_RADAU5(fvpol, jvpol, solout, bbampl, radau5); base._RKSolOut = new RKSolOut(this.contr5); }
/// <summary> /// Extract the solution from the tableau and evaluate it. /// </summary> /// <returns>Type of solution</returns> private void Result() { //------------------------------------------------- //extract the current solutionvector of the cost function value int zeroscounter = 0; for (int i = 0; i < variables.Length; i++) { if (variables[i] == -1) { solutionvector[i] = 0; } else { //solution of the basic variables on the left side of the tableau solutionvector[i] = tableau[variables[i], 0]; } if (Math.Abs(solutionvector[i]) < 1e-14) { zeroscounter++; } } targetfvalue = tableau[tableau.GetLength(0) - 1, 0]; //find out if it's a degenerated corner //if a beta value gets zero (|zeros| > n - m ) if (zeroscounter > variables.Length - (tableau.GetLength(0) - 1)) { this.solution = SOL.OPT_DEG_CORNER; throw (new DegenerateCornerException()); } //-------------------------------------------------- }
public StarpointObject(SOL library) { this.library = library; name = "New Object"; model = "Model Name.fbx"; xScale = 1; yScale = 1; zScale = 1; properties = new List <Property>(); properties.Add(new RealProperty("hp", true, "The hit points of this object.", 0f, 1, 1)); properties.Add(new RealProperty("armor", true, "The maximum damage this object can block before it takes damage to hit points.", 0f, null, 0)); properties.Add(new RealProperty("mass", true, "The mass of this object.", 0f, null, 0)); properties.Add(new RealProperty("max temperature", true, "The maximum temperature this object can reach before it is destroyed.", 0f, null, 0)); operations = new List <Operation>(); colliders = new List <StarpointCollider>(); }
/// <summary> /// Iteratively solve the linear problem. /// </summary> public void Solve() { try { //loop through as long as no optimal solution is found. //if there is no solution or a degenerate corner, an exception is thrown. while (CheckTableau() == SOL.NOT_OPT) { SetPivotRowCol(); ChangeTableau(); Result(); } } catch (NoSolutionException) { solution = SOL.NONE; } catch (DegenerateCornerException) { solution = SOL.OPT_DEG_CORNER; } }
public static SOL Load(string filepath) { if (File.Exists(filepath)) { FileStream fs = new FileStream(filepath, FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(SOL)); SOL sol = serializer.Deserialize(fs) as SOL; foreach (StarpointObject r in sol.objects) { r.library = sol; } return(sol); } else { throw new Exception(filepath + " doesn't exist!"); } }
private void LoadSols(string path) { foreach (string fse in Directory.GetFileSystemEntries(path)) { if (Directory.Exists(fse)) { LoadSols(fse); } else { if (Path.GetExtension(fse) == ".sol") { try { string f = Path.GetFileName(fse); string b = f.Split('.')[0]; string l = f.Split('.')[1]; if (!libraries.Exists(s => s.bundle == b && s.name == l)) { Debug.Log("Loading " + f); SOL sol = SOL.Load(fse); Debug.Log(fse + " version " + sol.version); libraries.Add(sol); } else { Debug.LogError("An SOL with the name " + f + " has already been loaded! >:("); } } catch (Exception e) { Debug.LogError("Failed to load " + Path.GetFileName(fse)); Debug.LogError(e.Message); if (e.InnerException != null) { Debug.LogError(e.InnerException.Message); } } } } } }
public StarpointObject Find(string name) { string bundle = name.Split('.')[0]; string library = name.Split('.')[1]; string obj = name.Split('.')[2]; if (libraries.Exists(s => s.bundle == bundle && s.name == library)) { SOL sol = libraries.Find(s => s.bundle == bundle && s.name == library); if (sol.objects.Exists(o => o.name == obj)) { return(sol.objects.Find(o => o.name == obj)); } else { Debug.LogError(bundle + "." + library + " doesn't contain an object by that name! Offending object: " + name); } } else { Debug.LogError("Couldn't find <bundle>.<library> " + bundle + "." + library + " in loaded SOLs! Offending object: " + name); } return(null); }
private SOL CheckTableau() { //-------------------------------------------------- //Check the cost function for the opt. solution for (int i = 0; i < variables.Length; i++) { if (variables[i] == -1) { //if on if the NBVs is less than zero, the optimum is not found yet. if (tableau[tableau.GetLength(0) - 1, i + 1] < 0.0) { return(this.solution = SOL.NOT_OPT); } else if (tableau[tableau.GetLength(0) - 1, i + 1] == 0.0) { //if one or more NBV coefficient in the cost function is zero, //there is an inifinite number of solution. S.14 (iv) return(this.solution = SOL.INF); } } } if (targetfvalue < 0.0) { //all NBV values in the cost function are non negative. //target function value is < 0 --> admissability range is empty. return(this.solution = SOL.RANGE_EMPTY); } else { return(this.solution = SOL.OPT); } //--------------------------------------------- }