///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "cafAppEnum.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include #include #include class RimSummaryCase; class RimSummaryCaseCollection; class RifEclipseSummaryAddress; class ObjectiveFunctionTimeConfig { public: time_t m_startTimeStep; time_t m_endTimeStep; std::vector m_timeSteps; }; //================================================================================================== /// //================================================================================================== class RimObjectiveFunction : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: caf::Signal<> changed; public: enum class FunctionType { F1 = 0, F2 }; QString shortName() const; RimObjectiveFunction::FunctionType functionType() const; RimObjectiveFunction(); void setFunctionType( RimObjectiveFunction::FunctionType functionType ); double value( RimSummaryCase* summaryCase, const std::vector& vectorSummaryAddresses, const ObjectiveFunctionTimeConfig& timeConfig, bool* hasWarning = nullptr ) const; std::pair minMaxValues( const std::vector& summaryCases, const std::vector& vectorSummaryAddresses, const ObjectiveFunctionTimeConfig& timeConfig ) const; QString formulaString( std::vector vectorSummaryAddresses ); bool operator<( const RimObjectiveFunction& other ) const; void hideFunctionSelection(); protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: double errorEstimate() const; std::vector timeStepIndicesForEvaluation( const std::vector& allTimeSteps, const ObjectiveFunctionTimeConfig& timeConfig ) const; double computeFunctionValue( const std::vector& summaryDiffValues, const std::vector& summaryHistoryValues, const std::vector& evaluationIndices ) const; private: caf::PdmField> m_functionType; caf::PdmField m_normalizeByNumberOfObservations; caf::PdmField m_errorEstimatePercentage; caf::PdmField m_useSquaredError; caf::PdmField m_normalizeByNumberOfVectors; };