138 Cycle(
const std::vector<linkInfo*>& linkList,
double infinite = 1000000):
141 opType(Data::BindingConstraint::opEquality),
144 uint columnImpedance = (uint)Antares::Data::fhlImpedances;
146 std::vector<double> impedances;
148 double currentLineSign = 1;
149 for (
auto line = linkList.begin(); line != linkList.end(); line++)
151 if ((*line)->nImpedanceChanges > 0
152 || ((*line)->type == Antares::Data::atAC && (!(*line)->hasPShiftsEqual)))
154 opType = Data::BindingConstraint::opBoth;
156 impedances.push_back((*line)->ptr->parameters[columnImpedance][0]);
158 time = HOURS_PER_YEAR;
161 if (line == linkList.begin())
167 if (previousLine->
with == (*line)->ptr->from
168 || previousLine->
from
169 == (*line)->ptr->with)
172 else if (previousLine->
from == (*line)->ptr->from
173 || previousLine->
with == (*line)->ptr->with)
175 currentLineSign *= -1;
179 assert(0 and
"links of the loops do not connect or are not in the right order");
183 sign.push_back(currentLineSign);
184 previousLine = (*line)->ptr;
186 State state(impedances, time, pInfinite);
187 states.push_back(state);
190 State& getState(std::vector<double>& impedances)
192 std::vector<State>::iterator stIT = std::find_if(states.begin(),
194 [&impedances](
State& s) ->
bool
195 { return s.impedances == impedances; });
197 if (stIT == states.end())
199 State state(impedances, time, pInfinite);
200 states.push_back(state);
201 stIT = std::find_if(states.begin(),
203 [&impedances](
State& s) ->
bool
204 { return s.impedances == impedances; });
210 std::vector<double> sign;
211 const std::vector<linkInfo*>& loop;
212 std::vector<State> states;
213 Data::BindingConstraint::Operator opType;
220 typedef std::vector<linkInfo*> Vector;
221 typedef std::map<linkInfo*, double> WeightMap;
222 typedef std::map<linkInfo*, double> Pattern;
223 typedef std::vector<Pattern> VectorOfPatterns;
224 typedef std::map<uint, Pattern*> Map;
252 bool saveCBuilderToFile(
const String& filename =
"")
const;
253 bool completeCBuilderFromFile(
const std::string& filename =
"");
263 auto linkIT = std::find_if(pLink.begin(),
265 [&u, &v](std::shared_ptr<linkInfo> edgeP) ->
bool
267 if (edgeP->ptr->from->id == u && edgeP->ptr->with->id == v)
271 if (edgeP->ptr->from->id == v && edgeP->ptr->with->id == u)
280 if (linkIT != pLink.end())
282 return linkIT->get();
292 for (
auto& area: pStudy.
areas)
294 auto a = area.second;
295 std::for_each(pLink.begin(),
297 [&a,
this](std::shared_ptr<linkInfo> edgeP)
299 if (edgeP->ptr->from == a || edgeP->ptr->with == a)
301 this->areaToLinks[a].insert(edgeP.get());
309 if (i < pLink.size())
311 return pLink[i].get();
328 bool createConstraints(
const std::vector<Vector>&);
330 double setInfinite(
const long value)
332 return infiniteSecondMember = value;
335 bool setCheckNodalLoopFlow(
const bool value)
337 return checkNodalLoopFlow = value;
340 bool setLoopFlowInclusion(
const bool value)
342 return includeLoopFlow = value;
345 bool setPhaseShiftInclusion(
const bool value)
347 return includePhaseShift = value;
352 return infiniteSecondMember;
355 bool getCheckNodalLoopFlow()
357 return checkNodalLoopFlow;
360 bool getLoopFlowInclusion()
362 return includeLoopFlow;
365 bool getPhaseShiftInclusion()
367 return includePhaseShift;
370 bool setUpToDate(
const bool value)
372 return isUpToDate = value;
389 void setCalendarStart(
int start)
391 calendarStart = start;
394 void setCalendarEnd(
int end)
399 uint getCalendarStart()
401 return calendarStart;
404 uint getCalendarEnd()
413 std::shared_ptr<Antares::Data::BindingConstraint> addConstraint(
414 const Data::ConstraintName& name,
415 const Yuni::String& op,
416 const Yuni::String& type,
417 const WeightMap& weights,
418 const double& secondMember);
421 std::vector<std::shared_ptr<linkInfo>> pLink;
425 std::string pPrefixDelete;
427 bool includeLoopFlow =
true;
428 bool includePhaseShift =
true;
429 bool isUpToDate =
false;
430 bool checkNodalLoopFlow =
true;
431 double infiniteSecondMember = 1000000;
433 uint calendarStart = 1;
434 uint calendarEnd = 8760;
436 std::vector<std::vector<linkInfo*>> pMesh;
438 std::map<Data::Area*, std::set<linkInfo*>> areaToLinks;
void fillColumn(uint x, const T &value)
Set a entire column with a given value.
Definition matrix.hxx:492