/usr/include/coin/IpNLPScaling.hpp is in coinor-libipopt-dev 3.11.9-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | // Copyright (C) 2004, 2007 International Business Machines and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// $Id: IpNLPScaling.hpp 2036 2011-07-02 17:21:08Z stefan $
//
// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
#ifndef __IPNLPSCALING_HPP__
#define __IPNLPSCALING_HPP__
#include "IpOptionsList.hpp"
#include "IpRegOptions.hpp"
namespace Ipopt
{
// forward declarations
class Vector;
class VectorSpace;
class Matrix;
class MatrixSpace;
class SymMatrix;
class SymMatrixSpace;
class ScaledMatrixSpace;
class SymScaledMatrixSpace;
/** This is the abstract base class for problem scaling.
* It is repsonsible for determining the scaling factors
* and mapping quantities in and out of scaled and unscaled
* versions
*/
class NLPScalingObject : public ReferencedObject
{
public:
/**@name Constructors/Destructors */
//@{
NLPScalingObject();
/** Default destructor */
virtual ~NLPScalingObject();
//@}
/** Method to initialize the options */
bool Initialize(const Journalist& jnlst,
const OptionsList& options,
const std::string& prefix)
{
jnlst_ = &jnlst;
return InitializeImpl(options, prefix);
}
/** Methods to map scaled and unscaled matrices */
//@{
/** Returns an obj-scaled version of the given scalar */
virtual Number apply_obj_scaling(const Number& f)=0;
/** Returns an obj-unscaled version of the given scalar */
virtual Number unapply_obj_scaling(const Number& f)=0;
/** Returns an x-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns an x-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_x(const SmartPtr<const Vector>& v)=0;
/** Returns an x-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns an x-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_x(const SmartPtr<const Vector>& v)=0;
/** Returns an c-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_c(const SmartPtr<const Vector>& v)=0;
/** Returns an c-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_c(const SmartPtr<const Vector>& v)=0;
/** Returns an c-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns an c-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns an d-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_d(const SmartPtr<const Vector>& v)=0;
/** Returns an d-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_d(const SmartPtr<const Vector>& v)=0;
/** Returns an d-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns an d-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0;
/** Returns a scaled version of the jacobian for c. If the
* overloaded method does not make a new matrix, make sure to set
* the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const Matrix>
apply_jac_c_scaling(SmartPtr<const Matrix> matrix)=0;
/** Returns a scaled version of the jacobian for d If the
* overloaded method does not create a new matrix, make sure to
* set the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const Matrix>
apply_jac_d_scaling(SmartPtr<const Matrix> matrix)=0;
/** Returns a scaled version of the hessian of the lagrangian If
* the overloaded method does not create a new matrix, make sure
* to set the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const SymMatrix>
apply_hessian_scaling(SmartPtr<const SymMatrix> matrix)=0;
//@}
/** Methods for scaling bounds - these wrap those above */
//@{
/** Returns an x-scaled vector in the x_L or x_U space */
SmartPtr<Vector> apply_vector_scaling_x_LU_NonConst(
const Matrix& Px_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& x_space);
/** Returns an x-scaled vector in the x_L or x_U space */
SmartPtr<const Vector> apply_vector_scaling_x_LU(
const Matrix& Px_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& x_space);
/** Returns an d-scaled vector in the d_L or d_U space */
SmartPtr<Vector> apply_vector_scaling_d_LU_NonConst(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space);
/** Returns an d-scaled vector in the d_L or d_U space */
SmartPtr<const Vector> apply_vector_scaling_d_LU(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space);
/** Returns an d-unscaled vector in the d_L or d_U space */
SmartPtr<Vector> unapply_vector_scaling_d_LU_NonConst(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space);
/** Returns an d-unscaled vector in the d_L or d_U space */
SmartPtr<const Vector> unapply_vector_scaling_d_LU(
const Matrix& Pd_LU,
const SmartPtr<const Vector>& lu,
const VectorSpace& d_space);
//@}
/** Methods for scaling the gradient of the objective - wraps the
* virtual methods above
*/
//@{
/** Returns a grad_f scaled version (d_f * D_x^{-1}) of the given vector */
virtual SmartPtr<Vector>
apply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v);
/** Returns a grad_f scaled version (d_f * D_x^{-1}) of the given vector */
virtual SmartPtr<const Vector>
apply_grad_obj_scaling(const SmartPtr<const Vector>& v);
/** Returns a grad_f unscaled version (d_f * D_x^{-1}) of the
* given vector */
virtual SmartPtr<Vector>
unapply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v);
/** Returns a grad_f unscaled version (d_f * D_x^{-1}) of the
* given vector */
virtual SmartPtr<const Vector>
unapply_grad_obj_scaling(const SmartPtr<const Vector>& v);
//@}
/** @name Methods for determining whether scaling for entities is
* done */
//@{
/** Returns true if the primal x variables are scaled. */
virtual bool have_x_scaling()=0;
/** Returns true if the equality constraints are scaled. */
virtual bool have_c_scaling()=0;
/** Returns true if the inequality constraints are scaled. */
virtual bool have_d_scaling()=0;
//@}
/** This method is called by the IpoptNLP's at a convenient time to
* compute and/or read scaling factors
*/
virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space,
const SmartPtr<const VectorSpace> c_space,
const SmartPtr<const VectorSpace> d_space,
const SmartPtr<const MatrixSpace> jac_c_space,
const SmartPtr<const MatrixSpace> jac_d_space,
const SmartPtr<const SymMatrixSpace> h_space,
SmartPtr<const MatrixSpace>& new_jac_c_space,
SmartPtr<const MatrixSpace>& new_jac_d_space,
SmartPtr<const SymMatrixSpace>& new_h_space,
const Matrix& Px_L, const Vector& x_L,
const Matrix& Px_U, const Vector& x_U)=0;
protected:
/** Implementation of the initialization method that has to be
* overloaded by for each derived class. */
virtual bool InitializeImpl(const OptionsList& options,
const std::string& prefix)=0;
/** Accessor method for the journalist */
const Journalist& Jnlst() const
{
return *jnlst_;
}
private:
/**@name Default Compiler Generated Methods
* (Hidden to avoid implicit creation/calling).
* These methods are not implemented and
* we do not want the compiler to implement
* them for us, so we declare them private
* and do not define them. This ensures that
* they will not be implicitly created/called. */
//@{
/** Copy Constructor */
NLPScalingObject(const NLPScalingObject&);
/** Overloaded Equals Operator */
void operator=(const NLPScalingObject&);
//@}
SmartPtr<const Journalist> jnlst_;
};
/** This is a base class for many standard scaling
* techniques. The overloaded classes only need to
* provide the scaling parameters
*/
class StandardScalingBase : public NLPScalingObject
{
public:
/**@name Constructors/Destructors */
//@{
StandardScalingBase();
/** Default destructor */
virtual ~StandardScalingBase();
//@}
/** Methods to map scaled and unscaled matrices */
//@{
/** Returns an obj-scaled version of the given scalar */
virtual Number apply_obj_scaling(const Number& f);
/** Returns an obj-unscaled version of the given scalar */
virtual Number unapply_obj_scaling(const Number& f);
/** Returns an x-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v);
/** Returns an x-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_x(const SmartPtr<const Vector>& v);
/** Returns an x-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v);
/** Returns an x-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_x(const SmartPtr<const Vector>& v);
/** Returns an c-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_c(const SmartPtr<const Vector>& v);
/** Returns an c-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_c(const SmartPtr<const Vector>& v);
/** Returns an c-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v);
/** Returns an c-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v);
/** Returns an d-scaled version of the given vector */
virtual SmartPtr<const Vector>
apply_vector_scaling_d(const SmartPtr<const Vector>& v);
/** Returns an d-unscaled version of the given vector */
virtual SmartPtr<const Vector>
unapply_vector_scaling_d(const SmartPtr<const Vector>& v);
/** Returns an d-scaled version of the given vector */
virtual SmartPtr<Vector>
apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v);
/** Returns an d-unscaled version of the given vector */
virtual SmartPtr<Vector>
unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v);
/** Returns a scaled version of the jacobian for c. If the
* overloaded method does not make a new matrix, make sure to set
* the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const Matrix>
apply_jac_c_scaling(SmartPtr<const Matrix> matrix);
/** Returns a scaled version of the jacobian for d If the
* overloaded method does not create a new matrix, make sure to
* set the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const Matrix>
apply_jac_d_scaling(SmartPtr<const Matrix> matrix);
/** Returns a scaled version of the hessian of the lagrangian If
* the overloaded method does not create a new matrix, make sure
* to set the matrix ptr passed in to NULL.
*/
virtual SmartPtr<const SymMatrix>
apply_hessian_scaling(SmartPtr<const SymMatrix> matrix);
//@}
/** @name Methods for determining whether scaling for entities is
* done */
//@{
virtual bool have_x_scaling();
virtual bool have_c_scaling();
virtual bool have_d_scaling();
//@}
/** This method is called by the IpoptNLP's at a convenient time to
* compute and/or read scaling factors
*/
virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space,
const SmartPtr<const VectorSpace> c_space,
const SmartPtr<const VectorSpace> d_space,
const SmartPtr<const MatrixSpace> jac_c_space,
const SmartPtr<const MatrixSpace> jac_d_space,
const SmartPtr<const SymMatrixSpace> h_space,
SmartPtr<const MatrixSpace>& new_jac_c_space,
SmartPtr<const MatrixSpace>& new_jac_d_space,
SmartPtr<const SymMatrixSpace>& new_h_space,
const Matrix& Px_L, const Vector& x_L,
const Matrix& Px_U, const Vector& x_U);
/** Methods for IpoptType */
//@{
static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
//@}
protected:
/** Overloaded initialization method */
virtual bool InitializeImpl(const OptionsList& options,
const std::string& prefix);
/** This is the method that has to be overloaded by a particular
* scaling method that somehow computes the scaling vectors dx,
* dc, and dd. The pointers to those vectors can be NULL, in
* which case no scaling for that item will be done later. */
virtual void DetermineScalingParametersImpl(
const SmartPtr<const VectorSpace> x_space,
const SmartPtr<const VectorSpace> c_space,
const SmartPtr<const VectorSpace> d_space,
const SmartPtr<const MatrixSpace> jac_c_space,
const SmartPtr<const MatrixSpace> jac_d_space,
const SmartPtr<const SymMatrixSpace> h_space,
const Matrix& Px_L, const Vector& x_L,
const Matrix& Px_U, const Vector& x_U,
Number& df,
SmartPtr<Vector>& dx,
SmartPtr<Vector>& dc,
SmartPtr<Vector>& dd)=0;
private:
/**@name Default Compiler Generated Methods
* (Hidden to avoid implicit creation/calling).
* These methods are not implemented and
* we do not want the compiler to implement
* them for us, so we declare them private
* and do not define them. This ensures that
* they will not be implicitly created/called. */
//@{
/** Copy Constructor */
StandardScalingBase(const StandardScalingBase&);
/** Overloaded Equals Operator */
void operator=(const StandardScalingBase&);
//@}
/** Scaling parameters - we only need to keep copies of
* the objective scaling and the x scaling - the others we can
* get from the scaled matrix spaces.
*/
//@{
/** objective scaling parameter */
Number df_;
/** x scaling */
SmartPtr<Vector> dx_;
//@}
/** Scaled Matrix Spaces */
//@{
/** Scaled jacobian of c space */
SmartPtr<ScaledMatrixSpace> scaled_jac_c_space_;
/** Scaled jacobian of d space */
SmartPtr<ScaledMatrixSpace> scaled_jac_d_space_;
/** Scaled hessian of lagrangian spacea */
SmartPtr<SymScaledMatrixSpace> scaled_h_space_;
//@}
/** @name Algorithmic parameters */
//@{
/** Additional scaling value for the objective function */
Number obj_scaling_factor_;
//@}
};
/** Class implementing the scaling object that doesn't to any scaling */
class NoNLPScalingObject : public StandardScalingBase
{
public:
/**@name Constructors/Destructors */
//@{
NoNLPScalingObject()
{}
/** Default destructor */
virtual ~NoNLPScalingObject()
{}
//@}
protected:
/** Overloaded from StandardScalingBase */
virtual void DetermineScalingParametersImpl(
const SmartPtr<const VectorSpace> x_space,
const SmartPtr<const VectorSpace> c_space,
const SmartPtr<const VectorSpace> d_space,
const SmartPtr<const MatrixSpace> jac_c_space,
const SmartPtr<const MatrixSpace> jac_d_space,
const SmartPtr<const SymMatrixSpace> h_space,
const Matrix& Px_L, const Vector& x_L,
const Matrix& Px_U, const Vector& x_U,
Number& df,
SmartPtr<Vector>& dx,
SmartPtr<Vector>& dc,
SmartPtr<Vector>& dd);
private:
/**@name Default Compiler Generated Methods
* (Hidden to avoid implicit creation/calling).
* These methods are not implemented and
* we do not want the compiler to implement
* them for us, so we declare them private
* and do not define them. This ensures that
* they will not be implicitly created/called. */
//@{
/** Copy Constructor */
NoNLPScalingObject(const NoNLPScalingObject&);
/** Overloaded Equals Operator */
void operator=(const NoNLPScalingObject&);
//@}
};
} // namespace Ipopt
#endif
|