Added per optimization parameter reduced pattern update functions for variable comparison

This commit is contained in:
iasonmanolas 2021-12-05 13:53:13 +02:00
parent 5d8d76e0c1
commit 6c92b291da
4 changed files with 779 additions and 457 deletions

View File

@ -29,7 +29,6 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(USE_POLYSCOPE FALSE) set(USE_POLYSCOPE FALSE)
set(MYSOURCES_STATIC_LINK TRUE) set(MYSOURCES_STATIC_LINK TRUE)
else() else()
add_compile_definitions(POLYSCOPE_DEFINED)
set(USE_POLYSCOPE TRUE) set(USE_POLYSCOPE TRUE)
add_compile_definitions(POLYSCOPE_DEFINED) add_compile_definitions(POLYSCOPE_DEFINED)
set(MYSOURCES_STATIC_LINK FALSE) set(MYSOURCES_STATIC_LINK FALSE)

View File

@ -47,8 +47,8 @@ int main(int argc, char *argv[]) {
ReducedPatternOptimization::xRange innerHexagonSize{"R", 0.05, 0.95}; ReducedPatternOptimization::xRange innerHexagonSize{"R", 0.05, 0.95};
ReducedPatternOptimization::xRange innerHexagonAngle{"Theta", -30.0, 30.0}; ReducedPatternOptimization::xRange innerHexagonAngle{"Theta", -30.0, 30.0};
ReducedPatternOptimization::Settings settings_optimization; ReducedPatternOptimization::Settings settings_optimization;
settings_optimization.xRanges settings_optimization.parameterRanges
= {/*beamE,*/ beamA, beamI2, beamI3, beamJ, innerHexagonSize, innerHexagonAngle}; = {beamE, beamA, beamI2, beamI3, beamJ, innerHexagonSize, innerHexagonAngle};
const bool input_numberOfFunctionCallsDefined = argc >= 4; const bool input_numberOfFunctionCallsDefined = argc >= 4;
settings_optimization.numberOfFunctionCalls = input_numberOfFunctionCallsDefined settings_optimization.numberOfFunctionCalls = input_numberOfFunctionCallsDefined
? std::atoi(argv[3]) ? std::atoi(argv[3])
@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
settings_optimization.objectiveWeights.rotational = 2 - std::atof(argv[4]); settings_optimization.objectiveWeights.rotational = 2 - std::atof(argv[4]);
std::string xConcatNames; std::string xConcatNames;
for (const auto &x : settings_optimization.xRanges) { for (const auto &x : settings_optimization.parameterRanges) {
xConcatNames.append(x.label + "_"); xConcatNames.append(x.label + "_");
} }
xConcatNames.pop_back(); xConcatNames.pop_back();
@ -117,7 +117,7 @@ int main(int argc, char *argv[]) {
const std::vector<size_t> numberOfNodesPerSlot{1, 0, 0, 2, 1, 2, 1}; const std::vector<size_t> numberOfNodesPerSlot{1, 0, 0, 2, 1, 2, 1};
assert(interfaceNodeIndex == numberOfNodesPerSlot[0] + numberOfNodesPerSlot[3]); assert(interfaceNodeIndex == numberOfNodesPerSlot[0] + numberOfNodesPerSlot[3]);
ReducedModelOptimizer optimizer(numberOfNodesPerSlot); ReducedModelOptimizer optimizer(numberOfNodesPerSlot);
optimizer.initializePatterns(fullPattern, reducedPattern, settings_optimization.xRanges); optimizer.initializePatterns(fullPattern, reducedPattern, settings_optimization.parameterRanges);
optimizer.optimize(settings_optimization, optimizationResults); optimizer.optimize(settings_optimization, optimizationResults);
optimizationResults.label = optimizationName; optimizationResults.label = optimizationName;
optimizationResults.baseTriangleFullPattern.copy(fullPattern); optimizationResults.baseTriangleFullPattern.copy(fullPattern);

File diff suppressed because it is too large Load Diff

View File

@ -36,8 +36,22 @@ class ReducedModelOptimizer
constructBaseScenarioFunctions; constructBaseScenarioFunctions;
std::vector<bool> scenarioIsSymmetrical; std::vector<bool> scenarioIsSymmetrical;
int fullPatternNumberOfEdges; int fullPatternNumberOfEdges;
constexpr static double youngsModulus{1 * 1e9};
public: public:
constexpr static struct ParameterLabels
{
inline const static std::string E = {"E"};
inline const static std::string A = {"A"};
inline const static std::string I2 = {"I2"};
inline const static std::string I3 = {"I3"};
inline const static std::string J = {"J"};
inline const static std::string theta = {"Theta"};
inline const static std::string R = {"R"};
} parameterLabels;
enum OptimizationParameterIndex { E, A, I2, I3, J, R, Theta, NumberOfOptimizationParameters };
constexpr static std::array<int, 5> simulationScenariosResolution = {11, 11, 20, 20, 20}; constexpr static std::array<int, 5> simulationScenariosResolution = {11, 11, 20, 20, 20};
// constexpr static std::array<int, 5> simulationScenariosResolution = {3, 3, 3, 3, 3}; // constexpr static std::array<int, 5> simulationScenariosResolution = {3, 3, 3, 3, 3};
inline static int totalNumberOfSimulationScenarios inline static int totalNumberOfSimulationScenarios
@ -74,15 +88,6 @@ public:
static void runSimulation(const std::string &filename, std::vector<double> &x); static void runSimulation(const std::string &filename, std::vector<double> &x);
static double objective(double x2,
double A,
double J,
double I2,
double I3,
double x3,
double innerHexagonRotationAngle);
static double objective(double b, double r, double E);
static std::vector<std::shared_ptr<SimulationJob>> createFullPatternSimulationJobs( static std::vector<std::shared_ptr<SimulationJob>> createFullPatternSimulationJobs(
const std::shared_ptr<SimulationMesh> &pMesh, const std::shared_ptr<SimulationMesh> &pMesh,
const std::unordered_map<size_t, size_t> &fullPatternOppositeInterfaceViMap); const std::unordered_map<size_t, size_t> &fullPatternOppositeInterfaceViMap);
@ -179,31 +184,31 @@ public:
&oppositeInterfaceViPairs, &oppositeInterfaceViPairs,
SimulationJob &job); SimulationJob &job);
static std::function<void(const dlib::matrix<double, 0, 1> &x, static std::function<void(const dlib::matrix<double, 0, 1> &x,
std::shared_ptr<SimulationMesh> &m)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern; function_updateReducedPattern;
static std::function<void(const dlib::matrix<double, 0, 1> &x, static std::function<void(const dlib::matrix<double, 0, 1> &x,
std::shared_ptr<SimulationMesh> &m)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material; function_updateReducedPattern_material;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newE,
const double &newE)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_E; function_updateReducedPattern_material_E;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newA,
const double &newA)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_A; function_updateReducedPattern_material_A;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newI,
const double &newI)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_I; function_updateReducedPattern_material_I;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newI2,
const double &newI2)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_I2; function_updateReducedPattern_material_I2;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newI3,
const double &newI3)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_I3; function_updateReducedPattern_material_I3;
static std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, static std::function<void(const double &newJ,
const double &newJ)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_material_J; function_updateReducedPattern_material_J;
static std::function<void(const dlib::matrix<double, 0, 1> &x, static std::function<void(const dlib::matrix<double, 0, 1> &x,
std::shared_ptr<SimulationMesh> &m)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
function_updateReducedPattern_geometry; function_updateReducedPattern_geometry;
private: private:
@ -223,7 +228,6 @@ private:
const std::shared_ptr<SimulationMesh> &mesh, const std::shared_ptr<SimulationMesh> &mesh,
const std::vector<ReducedPatternOptimization::xRange> &optimizationParamters); const std::vector<ReducedPatternOptimization::xRange> &optimizationParamters);
static double objective(long n, const double *x);
DRMSimulationModel simulator; DRMSimulationModel simulator;
void computeObjectiveValueNormalizationFactors(); void computeObjectiveValueNormalizationFactors();
static void getResults(const dlib::function_evaluation &optimizationResult_dlib, static void getResults(const dlib::function_evaluation &optimizationResult_dlib,
@ -242,30 +246,32 @@ private:
&desiredBaseSimulationScenarioIndices); &desiredBaseSimulationScenarioIndices);
static double objective(const dlib::matrix<double, 0, 1> &x); static double objective(const dlib::matrix<double, 0, 1> &x);
static void initializeUpdateReducedPatternFunctions(); static void initializeUpdateReducedPatternFunctions();
static double objective(const double &xValue);
}; };
inline std::function<void(const dlib::matrix<double, 0, 1> &x, std::shared_ptr<SimulationMesh> &m)>
ReducedModelOptimizer::function_updateReducedPattern;
inline std::function<void(const dlib::matrix<double, 0, 1> &x, std::shared_ptr<SimulationMesh> &m)> inline std::function<void(const dlib::matrix<double, 0, 1> &x, std::shared_ptr<SimulationMesh> &m)>
ReducedModelOptimizer::function_updateReducedPattern_material; ReducedModelOptimizer::function_updateReducedPattern_material;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newE,
const double &newE)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_E; ReducedModelOptimizer::function_updateReducedPattern_material_E;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newA,
const double &newA)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_A; ReducedModelOptimizer::function_updateReducedPattern_material_A;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newI,
const double &newI)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_I; ReducedModelOptimizer::function_updateReducedPattern_material_I;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newI2,
const double &newI2)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_I2; ReducedModelOptimizer::function_updateReducedPattern_material_I2;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newI3,
const double &newI3)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_I3; ReducedModelOptimizer::function_updateReducedPattern_material_I3;
inline std::function<void(std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh, inline std::function<void(const double &newJ,
const double &newJ)> std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh)>
ReducedModelOptimizer::function_updateReducedPattern_material_J; ReducedModelOptimizer::function_updateReducedPattern_material_J;
inline std::function<void(const dlib::matrix<double, 0, 1> &x, std::shared_ptr<SimulationMesh> &m)> inline std::function<void(const dlib::matrix<double, 0, 1> &x, std::shared_ptr<SimulationMesh> &m)>
ReducedModelOptimizer::function_updateReducedPattern_geometry; ReducedModelOptimizer::function_updateReducedPattern_geometry;
inline std::function<void(const dlib::matrix<double, 0, 1> &x,
std::shared_ptr<SimulationMesh> &m)>
ReducedModelOptimizer::function_updateReducedPattern;
#endif // REDUCEDMODELOPTIMIZER_HPP #endif // REDUCEDMODELOPTIMIZER_HPP