public stressConstraint(ForceVelocityPositionAnalysis fvpAnalysis, double Nf, double SFB, double SFC) { FVPAnalysis = fvpAnalysis; this.Nf = Nf; this.SFB = SFB; this.SFC = SFC; }
public boundingboxConstraint(ForceVelocityPositionAnalysis fvpAnalysis, double minX, double maxX, double minY, double maxY, double minZ, double maxZ) { FVPAnalysis = fvpAnalysis; this.minX = minX; this.maxX = maxX; this.minY = minY; this.maxY = maxY; this.minZ = minZ; this.maxZ = maxZ; }
public outputLocationConstraint(ForceVelocityPositionAnalysis fvpAnalysis, double tolerance, double xtarget, double ytarget, double ztarget) // double thetaX, double thetaY, double thetaZ) { FVPAnalysis = fvpAnalysis; this.tolerance = tolerance; this.xtarget = xtarget; this.ytarget = ytarget; this.ztarget = ztarget; //this.thetaX = thetaX; //this.thetaY = thetaY; //this.thetaZ = thetaZ; }
public massObjective(ForceVelocityPositionAnalysis fvpsAnalysis, double gearDensity) { FVPAnalysis = fvpsAnalysis; numberGears = fvpsAnalysis.numGears; this.gearDensity = gearDensity; }
public outputSpeedConstraint(ForceVelocityPositionAnalysis fvpAnalysis, double targetSpeed, double tolerance) { FVPAnalysis = fvpAnalysis; this.targetSpeed = targetSpeed; this.tolerance = tolerance; }
// This is the set of valid AGMA gear pitches (in unit of inch^-1). private static void Main() { //var opty = new GradientBasedOptimization(); //var opty = new HillClimbing(); var opty = new GeneticAlgorithm(100); var numGears = 2 * NumGearPairs; /* here is the Dependent Analysis. Take a look at the file/class ForceVelocityPositionAnalysis.cs * and notice that it inherits from IDependent Analysis. By adding this to the optimization method * (line 122), we are ensuring that it is called for any new decision variables found in the process.*/ var FVPAnalysis = new ForceVelocityPositionAnalysis(numGears, outputTorque, inputSpeed, inputPosition); opty.Add(FVPAnalysis); /* here is the objective function, minimize mass. Note that it will hold a reference to the * ForceVelocityPositionAnalysis so that it can reference it for exact values of diamter. */ opty.Add(new massObjective(FVPAnalysis, gearDensity)); /* here is an inequality constraint for fitting within the box described above. Again, it * needs to position and diameter information stored in ForceVelocityPositionAnalysis */ opty.Add(new boundingboxConstraint(FVPAnalysis, boxMinX, boxMaxX, boxMinY, boxMaxY, boxMinZ, boxMaxZ)); /* on and on: stress inequality, output Location, output Speed equalities. Details can be found in * http://dx.doi.org/10.1115/DETC2009-86780 */ opty.Add(new stressConstraint(FVPAnalysis, Nf, SFB, SFC)); opty.Add(new outputLocationConstraint(FVPAnalysis, locationTol, outputX, outputY, outputZ)); opty.Add(new outputSpeedConstraint(FVPAnalysis, speedTol, outputSpeed)); for (var i = 0; i < NumGearPairs - 1; i++) { // each mating gear pair must have the same pitch. opty.Add(new samePitch(i * 4 + 1, (i + 1) * 4 + 1)); } /******** Set up Design Space *************/ /* for the GA and the Hill Climbing, a compete discrete space is needed. Face width and * location parameters should be continuous though. Consider removing the 800's below * when using a mixed optimization method. */ var dsd = new DesignSpaceDescription(numGears * 4); for (var i = 0; i < numGears; i++) { dsd[4 * i] = new VariableDescriptor(5, 1000, 1.0); // number of teeth: integers between 5 and 1000 dsd[4 * i + 1] = new VariableDescriptor(ValidPitches); // pitches from AGMA standard dsd[4 * i + 2] = new VariableDescriptor(0, 50, 800); // face width is between 0 and 50 inches dsd[4 * i + 3] = new VariableDescriptor(0, 500, 800); //location is either an angle or a length // a max of 500 inches is generous } opty.Add(dsd); /******** Set up Optimization *************/ /* the following mish-mash is similiar to previous project - just trying to find a * combination of methods that'll lead to the optimial optimization algorithm. */ //abstractSearchDirection searchDirMethod = new SteepestDescent(); //opty.Add(searchDirMethod); //abstractLineSearch lineSearchMethod = new ArithmeticMean(0.0001, 1, 100); //opty.Add(lineSearchMethod); opty.Add(new LatinHyperCube(dsd, VariablesInScope.BothDiscreteAndReal)); opty.Add(new GACrossoverBitString(dsd)); opty.Add(new GAMutationBitString(dsd)); opty.Add(new PNormProportionalSelection(optimize.minimize, true, 0.7)); //opty.Add(new RandomNeighborGenerator(dsd,3000)); //opty.Add(new KeepSingleBest(optimize.minimize)); opty.Add(new squaredExteriorPenalty(opty, 10)); opty.Add(new MaxAgeConvergence(40, 0.001)); opty.Add(new MaxFnEvalsConvergence(10000)); opty.Add(new MaxSpanInPopulationConvergence(15)); double[] xStar; Parameters.Verbosity = VerbosityLevels.AboveNormal; // this next line is to set the Debug statements from OOOT to the Console. Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); var timer = Stopwatch.StartNew(); var fStar = opty.Run(out xStar, numGears * 4); printResults(opty, xStar, fStar, timer); Console.ReadKey(); }