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
// Copyright (C) 2007 International Business Machines and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// Authors: Lifeng Chen/Zaiwen Wen Columbia Univ
#ifndef __IPPIECEWISEPENALTY_HPP__
#define __IPPIECEWISEPENALTY_HPP__
#include "IpJournalist.hpp"
#include "IpDebug.hpp"
#include "IpOptionsList.hpp"
#include "IpIpoptCalculatedQuantities.hpp"
#include "IpBacktrackingLSAcceptor.hpp"
#include "IpPDSystemSolver.hpp"
#include <list>
#include <vector>
namespace Ipopt
{
/** struct for one Piecewise Penalty entry. */
typedef struct PiecewisePenEntry
{
Number pen_r;
Number barrier_obj;
Number infeasi;
} PiecewisePenEntry;
/** Class for the Piecewise Penalty.
*
* This class contains all Piecewise Penalty entries.
* The entries are stored as the corner point, including the
* margin.
*/
class PiecewisePenalty
{
public:
/**@name Constructors/Destructors */
///@{
/** Default Constructor */
PiecewisePenalty(
Index dim);
/** Destructor */
~PiecewisePenalty()
{
// ToDo figure out if that here is necessary
// Clear();
}
///@}
///@{
// Initialize Piecewise Penalty list
bool IsPiecewisePenaltyListEmpty()
{
return PiecewisePenalty_list_.empty();
}
void InitPiecewisePenaltyList(
Number pen_r,
Number barrier_obj,
Number infeasi)
{
AddEntry(pen_r, barrier_obj, infeasi);
}
/** Check acceptability of given coordinates with respect
* to the Piecewise Penalty.
*
* @return true, if pair is acceptable
*/
bool Acceptable(
Number Fzconst,
Number Fzlin
);
/** Get the value of the biggest barrier function so far */
Number BiggestBarr();
/** Update Piecewise Penalty entry for given coordinates. */
void UpdateEntry(
Number barrier_obj,
Number infeasi );
/** Add a entry to the list */
void AddEntry(
Number pen_r,
Number barrier_obj,
Number infeasi
)
{
PiecewisePenEntry TmpEntry;
if( IsPiecewisePenaltyListEmpty() )
{
TmpEntry.pen_r = 0.0;
}
else
{
TmpEntry.pen_r = pen_r;
}
TmpEntry.barrier_obj = barrier_obj;
TmpEntry.infeasi = infeasi;
PiecewisePenalty_list_.push_back(TmpEntry);
}
/** Clear and reset the piecewise penalty list */
void ResetList(
Number pen_r,
Number barrier_obj,
Number infeasi
)
{
PiecewisePenalty_list_.clear();
AddEntry(pen_r, barrier_obj, infeasi);
}
///@}
/** Delete all Piecewise Penalty entries */
void Clear()
{
PiecewisePenalty_list_.clear();
}
/** Print current Piecewise Penalty entries */
void Print(
const Journalist& 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.
*/
///@{
/** Default Constructor */
PiecewisePenalty();
/** Copy Constructor */
PiecewisePenalty(
const PiecewisePenalty&
);
/** Default Assignment Operator */
void operator=(
const PiecewisePenalty&
);
///@}
/** Dimension of the Piecewise Penalty (number of coordinates per entry) */
Index dim_;
/** The min penalty value for the piecewise penalty list */
Number min_piece_penalty_;
/** The max number of the break points in the piecewise penalty list */
Index max_piece_number_;
/** vector storing the Piecewise Penalty entries */
std::vector<PiecewisePenEntry> PiecewisePenalty_list_;
};
} // namespace Ipopt
#endif