44 Foam::SQPBase::SQPBase
58 UpdateMethod.nConstraints(),
61 LagrangianDerivatives_(designVars().getVars().size(),
Zero),
62 constraintDerivativesOld_
64 UpdateMethod.nConstraints(),
69 UpdateMethod.
found(
"lamdas") ?
70 scalarField(
"lamdas", UpdateMethod, UpdateMethod.nConstraints()) :
75 mesh.time().globalPath()/
"optimisation"/
"objective"/
78 meritFunctionFile_(nullptr),
82 UpdateMethod.coeffsDict(
type).getOrDefault<scalar>(
"delta", 0.1)
111 forAll(constraintDerivativesOld_, cI)
113 constraintDerivativesOld_[cI].
114 writeEntry(
"constraintDerivativesOld" +
Foam::name(cI),
os);
116 lamdas_.writeEntry(
"lamdas",
os);
124 scalar objectivePart = UpdateMethod.getObjectiveValue();
125 scalar constraintPart = mu_*meritFunctionConstraintPart();
126 scalar merit = objectivePart + constraintPart;
127 const scalarField& cValues = UpdateMethod.getConstraintValues();
131 unsigned int constraintsSize = lamdas_.size();
132 constraintsSize = constraintsSize*(width + 1) + 2;
135 if (!meritFunctionFile_)
137 meritFunctionFile_.reset
139 new OFstream(objFunctionFolder_/word(
"meritFunction"))
143 <<
setw(1) <<
"#" <<
" " 144 <<
setw(width) <<
"merit" <<
" " 145 <<
setw(width) <<
"J" <<
" " 146 <<
setw(constraintsSize) <<
"lamdas" <<
" " 147 <<
setw(constraintsSize) <<
"constraints" <<
" " 148 <<
setw(width) <<
"mu" <<
" " 149 <<
setw(width) <<
"constraintContr" <<
endl;
154 <<
setw(1) << UpdateMethod.getCycle() <<
" " 155 <<
setw(width) << merit <<
" " 156 <<
setw(width) << objectivePart <<
" " 162 <<
setw(width) << lamdas_[cI] <<
setw(1) <<
" ";
164 meritFunctionFile_() <<
setw(3) <<
")(";
168 <<
setw(width) << cValues[cI] <<
setw(1) <<
" ";
170 meritFunctionFile_() <<
setw(2) <<
") ";
171 meritFunctionFile_() <<
setw(width) << mu_ <<
" ";
172 meritFunctionFile_() <<
setw(width) << constraintPart <<
endl;
void size(const label n)
Older name for setAddressableSize.
Abstract base class for optimisation methods supporting constraints. Does not add functionality to up...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Abstract base class for optimisation methods.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool addToFile(Ostream &os) const
Write continuation info.
static unsigned int defaultPrecision() noexcept
Return the default precision.
scalarField LagrangianDerivatives_
Derivatives of the Lagrangian function.
Macros for easy insertion into run-time selection tables.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
#define forAll(list, i)
Loop across all elements in list.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< scalarField > constraintDerivativesOld_
The previous constraint derivatives.
Base class for Sequantial Quadratic Programming (SQP) methods.
Istream and Ostream manipulators taking arguments.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
virtual bool writeMeritFunction(const updateMethod &UpdateMethod)
Write info about the merit function.
Mesh data needed to do the Finite Volume discretisation.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
scalarField lamdas_
Lagrange multipliers.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Omanip< int > setw(const int i)
fileName objFunctionFolder_
Name of the objective folder.
static constexpr const zero Zero
Global zero (0)