6 #ifndef ClpHelperFunctions_H
7 #define ClpHelperFunctions_H
16 # error "don't have header file for math"
29 void setElements(
double * region,
int size,
double value);
30 void multiplyAdd(
const double * region1,
int size,
double multiplier1,
31 double * region2,
double multiplier2);
32 double innerProduct(
const double * region1,
int size,
const double * region2);
33 void getNorms(
const double * region,
int size,
double & norm1,
double & norm2);
45 for (
int i = 0; i < size; i++)
51 for (
int i = 0; i < size; i++)
52 to[i] = static_cast<double>(from[i]);
57 return (x1 > x2) ? x1 : x2;
62 return (x1 > x2) ? x1 : x2;
67 return (x1 < x2) ? x1 : x2;
72 return (x1 < x2) ? x1 : x2;
86 # define ClpTraceDebug(expression) {}
88 void ClpTracePrint(std::string fileName, std::string message,
int line);
89 # define ClpTraceDebug(expression) { \
90 if (!(expression)) { ClpTracePrint(__FILE__,__STRING(expression),__LINE__); } \
110 for (
int k = 0; k < nlow; k++) {
111 sum1 += rL[low[k]] * rL[low[k]];
112 sum2 += cL[low[k]] * cL[low[k]];
117 for (
int k = 0; k < nupp; k++) {
118 sum1 += rL[upp[k]] * rL[upp[k]];
119 sum2 += cL[upp[k]] * cL[upp[k]];
136 inline void pdxxxresid1(
ClpPdco *model,
const int nlow,
const int nupp,
const int nfix,
137 int *low,
int *upp,
int *fix,
155 for (
int k = 0; k < nfix; k++)
162 for (
int k = 0; k < nfix; k++)
166 r1 = b - r1 - d2 * d2 * y;
171 for (
int k = 0; k < nlow; k++)
172 rL[low[k]] = bl[low[k]] - x[low[k]] + x1[low[k]];
173 for (
int k = 0; k < nupp; k++)
174 rU[upp[k]] = - bu[upp[k]] + x[upp[k]] + x2[upp[k]];
178 for (
int k = 0; k < nlow; k++)
179 if (rL[low[k]] > normL) normL = rL[low[k]];
180 for (
int k = 0; k < nupp; k++)
181 if (rU[upp[k]] > normU) normU = rU[upp[k]];
186 *Pinf =
CoinMax( *Pinf, 1e-99 );
187 *Dinf =
CoinMax( *Dinf, 1e-99 );
198 inline void pdxxxresid2(
double mu,
int nlow,
int nupp,
int *low,
int *upp,
202 double *center,
double *Cinf,
double *Cinf0)
211 double maxXz = -1e20;
217 for (
int k = 0; k < nlow; k++) {
218 double x1z1 = x1_elts[low[k]] * z1_elts[low[k]];
219 cL_elts[low[k]] = mu - x1z1;
220 if (x1z1 > maxXz) maxXz = x1z1;
221 if (x1z1 < minXz) minXz = x1z1;
227 for (
int k = 0; k < nupp; k++) {
228 double x2z2 = x2_elts[upp[k]] * z2_elts[upp[k]];
229 cU_elts[upp[k]] = mu - x2z2;
230 if (x2z2 > maxXz) maxXz = x2z2;
231 if (x2z2 < minXz) minXz = x2z2;
234 maxXz =
CoinMax( maxXz, 1e-99 );
235 minXz =
CoinMax( minXz, 1e-99 );
236 *center = maxXz / minXz;
240 for (
int k = 0; k < nlow; k++)
241 if (cL_elts[low[k]] > normL) normL = cL_elts[low[k]];
242 for (
int k = 0; k < nupp; k++)
243 if (cU_elts[upp[k]] > normU) normU = cU_elts[upp[k]];
244 *Cinf =
CoinMax( normL, normU);
262 for (
int k = 0; k < n; k++)
264 if ((x_elts[k] / (-dx_elts[k])) < step)
265 step = x_elts[k] / (-dx_elts[k]);
283 for (
int k = 0; k < n; k++)
285 if ((x_elts[k] / (-dx_elts[k])) < step)
286 step = x_elts[k] / (-dx_elts[k]);
T CoinMax(register const T x1, register const T x2)
Return the larger (according to operator<() of the arguments.
void matVecMult(int, double *, double *)
LSQR.
void getNorms(const double *region, int size, double &norm1, double &norm2)
const T * getElements() const
Get element values.
void setElements(double *region, int size, double value)
T infNorm() const
infinity-norm of vector
void ClpTracePrint(std::string fileName, std::string message, int line)
Trace.
double maximumAbsElement(const double *region, int size)
Note (JJF) I have added some operations on arrays even though they may duplicate CoinDenseVector.
void CoinMemcpyN(register const T *from, const int size, register T *to)
This helper function copies an array to another location.
void clear()
Reset the vector (i.e. set all elemenets to zero)
double innerProduct(const double *region1, int size, const double *region2)
int size() const
Get the size.
This solves problems in Primal Dual Convex Optimization.
T CoinMin(register const T x1, register const T x2)
Return the smaller (according to operator<() of the arguments.
double CoinSqrt(double x)
double twoNorm() const
2-norm of vector
void multiplyAdd(const double *region1, int size, double multiplier1, double *region2, double multiplier2)