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