| 3044 | } |
| 3045 | |
| 3046 | std::vector<Simulation*> ParametricGridData::PrepareSimulations() { |
| 3047 | SimulationDialog tpd("Preparing simulations...", 1); |
| 3048 | std::vector<Simulation*> sims; |
| 3049 | int total_runs = 0; |
| 3050 | for (size_t i = 0; i < m_par.Runs.size(); i++) |
| 3051 | if (!m_valid_run[i]) total_runs++; |
| 3052 | if (total_runs == 0) total_runs = m_par.Runs.size(); |
| 3053 | |
| 3054 | for (size_t i = 0; i < m_par.Runs.size(); i++) |
| 3055 | { |
| 3056 | // reset all simulation objects to copy over latest value if changed on input page (no listeners) |
| 3057 | m_valid_run[i] = false; |
| 3058 | |
| 3059 | if (!m_valid_run[i]) |
| 3060 | { |
| 3061 | m_par.Runs[i]->Clear(); |
| 3062 | |
| 3063 | for (int col = 0; col < m_cols; col++) |
| 3064 | { |
| 3065 | if (IsInput(col)) |
| 3066 | { |
| 3067 | if (VarValue* vv = &m_par.Setup[col].Values[i]) |
| 3068 | { |
| 3069 | // set for simulation |
| 3070 | // m_par.Runs[i]->Override(m_var_names[col], *vv, m_par.Setup[col].ndxHybrid); // TODO: hybrids |
| 3071 | m_par.Runs[i]->Override(m_par.Setup[col].varName, *vv, m_par.Setup[col].ndxHybrid); |
| 3072 | } |
| 3073 | } |
| 3074 | } |
| 3075 | // Excel exchange if necessary |
| 3076 | ExcelExchange& ex = m_case->ExcelExch(); |
| 3077 | if (ex.Enabled) { |
| 3078 | for (size_t ndxHybrids = 0; ndxHybrids < m_case->GetConfiguration()->Technology.size(); ndxHybrids++) |
| 3079 | ExcelExchange::RunExcelExchange(ex, m_case->Values(ndxHybrids), m_par.Runs[i]); |
| 3080 | } |
| 3081 | |
| 3082 | if (!m_par.Runs[i]->Prepare()) |
| 3083 | wxMessageBox(wxString::Format("internal error preparing simulation %d for parametric: %s", (int)(i + 1), m_par.Runs[i]->GetErrors()[0])); |
| 3084 | |
| 3085 | tpd.Update(0, (float)i / (float)total_runs * 100.0f, wxString::Format("%d of %d", (int)(i + 1), (int)total_runs)); |
| 3086 | } |
| 3087 | |
| 3088 | m_par.Runs[i]->SetName(wxString::Format("Parametric #%d", (int)(i + 1))); |
| 3089 | sims.push_back(m_par.Runs[i]); |
| 3090 | } |
| 3091 | return sims; |
| 3092 | } |
| 3093 | |
| 3094 | bool ParametricGridData::RunSimulations_multi() |
| 3095 | { |
no test coverage detected