Refactoring
This commit is contained in:
parent
94408b7a74
commit
99f6905e12
12
src/main.cpp
12
src/main.cpp
|
@ -23,15 +23,9 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
// ReducedModelOptimization::Results optResults;
|
||||
// optResults.load("/home/iason/Desktop/dlib_ensmallen_comparison/TestSets/"
|
||||
// "singlePattern_dlib_firstSubmission/12@single_reduced(100000_1.20)");
|
||||
// optResults.load("/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/Results/OptimizationResults/"
|
||||
// "objectiveFunction/ConvergedJobs/testSet/7#12");
|
||||
// optResults.load("/home/iason/Desktop/dlib_ensmallen_comparison/TestSets/"
|
||||
// "singlePattern_dlib_23_12/12@single_reduced(100000_1.20)");
|
||||
// optResults.load("/home/iason/Desktop/dlib_ensmallen_comparison/TestSets/"
|
||||
// "singlePattern_ensmallen_AllVars_optParameters/7#12");
|
||||
// optResults.load("/home/iason/Desktop/finding_submissionCode/"
|
||||
// "build-ReducedModelOptimization-Clang-RelWithDebInfo/OptimizationResults/"
|
||||
// "ConvergedJobs/12@single_reduced(100000_1.20)");
|
||||
// ReducedModelEvaluator::evaluateReducedModel(optResults);
|
||||
if (argc <= 5) {
|
||||
std::cerr << "Wrong number of input parameters. Expects at least 4 input parameters."
|
||||
|
|
|
@ -186,7 +186,8 @@ struct EnsmallenOptimizationObjective
|
|||
//#ifdef POLYSCOPE_DEFINED
|
||||
// std::cout << "Out of range" << std::endl;
|
||||
//#endif
|
||||
// return std::numeric_limits<double>::max();
|
||||
// return std::numeric_limits<double>::max();
|
||||
// return 1e7;
|
||||
// return 1000;
|
||||
x[xi] = global.xMax[xi];
|
||||
} else if (x[xi] < global.xMin[xi]) {
|
||||
|
@ -194,6 +195,7 @@ struct EnsmallenOptimizationObjective
|
|||
// std::cout << "Out of range" << std::endl;
|
||||
//#endif
|
||||
// return std::numeric_limits<double>::max();
|
||||
// return 1e7;
|
||||
// return 1000;
|
||||
x[xi] = global.xMin[xi];
|
||||
}
|
||||
|
@ -1093,10 +1095,10 @@ void ReducedModelOptimizer::runOptimization(const Settings &settings,
|
|||
// that is able to handle arbitrary functions.
|
||||
EnsmallenOptimizationObjective optimizationFunction;
|
||||
//Set min max values
|
||||
// ens::SA optimizer;
|
||||
// ens::CNE optimizer;
|
||||
// ens::DE optimizer;
|
||||
// ens::SPSA optimizer;
|
||||
// ens::SA optimizer;
|
||||
// ens::CNE optimizer;
|
||||
// ens::DE optimizer;
|
||||
// ens::SPSA optimizer;
|
||||
// arma::mat xMin_arma(global.xMin);
|
||||
// arma::mat xMax_arma(global.xMax);
|
||||
// ens::LBestPSO optimizer(64, xMin_arma, xMax_arma, 1000);
|
||||
|
@ -1110,13 +1112,13 @@ void ReducedModelOptimizer::runOptimization(const Settings &settings,
|
|||
2.35);
|
||||
// ens::LBestPSO optimizer;
|
||||
const double minima = optimizer.Optimize(optimizationFunction, x);
|
||||
// for (int xIndex = 0; xIndex < parameterGroup.size(); xIndex++) {
|
||||
// if (x[xIndex] > global.xMax[xIndex]) {
|
||||
// x[xIndex] = global.xMax[xIndex];
|
||||
// } else if (x[xIndex] < global.xMin[xIndex]) {
|
||||
// x[xIndex] = global.xMin[xIndex];
|
||||
// }
|
||||
// }
|
||||
for (int xIndex = 0; xIndex < parameterGroup.size(); xIndex++) {
|
||||
if (x[xIndex] > global.xMax[xIndex]) {
|
||||
x[xIndex] = global.xMax[xIndex];
|
||||
} else if (x[xIndex] < global.xMin[xIndex]) {
|
||||
x[xIndex] = global.xMin[xIndex];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef POLYSCOPE_DEFINED
|
||||
std::cout << "optimal x:"
|
||||
|
@ -1868,7 +1870,7 @@ void ReducedModelOptimizer::optimize(
|
|||
global.optimizationSettings = optimizationSettings;
|
||||
global.pFullPatternSimulationMesh = m_pFullPatternSimulationMesh;
|
||||
|
||||
constexpr bool recomputeForceMagnitudes = true;
|
||||
constexpr bool recomputeForceMagnitudes = false;
|
||||
std::array<double, NumberOfBaseSimulationScenarios> fullPatternSimulationScenarioMaxMagnitudes
|
||||
= getFullPatternMaxSimulationForces(desiredBaseSimulationScenarioIndices,
|
||||
intermediateResultsDirectoryPath,
|
||||
|
@ -1919,7 +1921,7 @@ void ReducedModelOptimizer::optimize(
|
|||
.append(m_pFullPatternSimulationMesh->getLabel())
|
||||
.append(pFullPatternSimulationJob->getLabel()));
|
||||
// .append(pFullPatternSimulationJob->getLabel() + ".json")
|
||||
constexpr bool recomputeFullPatternResults = true;
|
||||
constexpr bool recomputeFullPatternResults = false;
|
||||
SimulationResults fullPatternResults;
|
||||
if (!recomputeFullPatternResults && std::filesystem::exists(jobResultsDirectoryPath)) {
|
||||
fullPatternResults.load(std::filesystem::path(jobResultsDirectoryPath).append("Results"),
|
||||
|
|
Loading…
Reference in New Issue