📄 rrproj_solv.cpp
字号:
}
//----------------------------------------------------------------------
// g_opt - for making decisions
aipG rpsOption::g_opt() {
return ( aiprrOption::g_opt() + emp()->g_last_work() );
}
//----------------------------------------------------------------------
// g_opt_cmp - for comparing solutions
aipG rpsOption::g_opt_cmp() {
return ( aiprrOption::g_opt_cmp() + emp()->g_last_work() );
}
//----------------------------------------------------------------------
// g_opt_usr - for reporting to the user
aipG rpsOption::g_opt_usr() { // for reporting to the user
return ( aiprrOption::g_opt_usr() + emp()->g_last_work() );
}
//======================================================================
// rpsPosition
//
//----------------------------------------------------------------------
// constructor
rpsPosition::rpsPosition (long a_pos_id, rpsProblem *a_prob)
: aiprrRequirement(a_pos_id, a_prob) {
}
//----------------------------------------------------------------------
// add_posday
void rpsPosition::add_posday (rpsPosDay *x) {
add_reqday(x);
}
//----------------------------------------------------------------------
// take_msg - take and react to a message
void rpsPosition::take_msg (aipMsg *mm) {
aiprrRequirement::take_msg(mm);
// rpsMsg *m = (rpsMsg *)mm;
}
//----------------------------------------------------------------------
// Note that a decision for this position has been decided
// void rpsPosition::note_rps_decide (rpsDecision *d, rpsOption *o) {}
//----------------------------------------------------------------------
// return an iterator: position-days for the position
rpsPosDayItr rpsPosition::posday_iterator() const {
rpsPosDayItr i(reqday_pandemonium());
return i;
}
//======================================================================
// rpsPosDay
//
//----------------------------------------------------------------------
// constructor
//
// set_dcsn() must be called after the decision is created.
rpsPosDay::rpsPosDay(rpsPosition *a_pos, long a_yyyymmdd,
long a_proj_id,
long a_start_hhmm, long a_end_hhmm)
: aiprrReqDay(a_pos, a_yyyymmdd) {
m_proj_id = a_proj_id;
m_start_time = aipTime(a_yyyymmdd, a_start_hhmm);
m_end_time = aipTime(a_yyyymmdd, a_end_hhmm);
m_yyyymmdd = a_yyyymmdd;
// if posday crosses midnight...
if (m_end_time < m_start_time) m_end_time.add_days(1);
}
//----------------------------------------------------------------------
// Destructor
rpsPosDay::~rpsPosDay() {}
//----------------------------------------------------------------------
// take_msg - take and react to a message
void rpsPosDay::take_msg (aipMsg *mm) {
aiprrReqDay::take_msg(mm);
// rpsMsg *m = (rpsMsg *)mm;
}
//----------------------------------------------------------------------
// Note that a decision for this position-day has been decided
// void rpsPosDay::note_rps_decide (rpsDecision *d, rpsOption *o) { }
//======================================================================
// rpsEmployee
//
//----------------------------------------------------------------------
// constructor
rpsEmployee::rpsEmployee(long a_id, rpsProblem *a_prob)
: aiprrResource(a_id, a_prob) {
m_g_last_work = aipNeutral;
m_start_last_work = aipTime(20010203);
}
//----------------------------------------------------------------------
// destructor
rpsEmployee::~rpsEmployee() {}
//----------------------------------------------------------------------
// set_start_last_work
void rpsEmployee::set_start_last_work (aipTime x) {
m_start_last_work = x;
}
//----------------------------------------------------------------------
// add_empday
void rpsEmployee::add_empday (rpsEmpDay *x) {
add_resday(x);
}
//----------------------------------------------------------------------
// take_msg - take and react to a message
void rpsEmployee::take_msg (aipMsg *mm) {
aiprrResource::take_msg(mm);
rpsMsg *m = (rpsMsg *)mm;
if (m->typ() == HH_Starting_New_Try) {
aipTime limit_day(20020101);
if (m_start_last_work < limit_day) {
m_start_last_work = prob()->start_day();
}
long days_since_work =
prob()->start_day().days_since(m_start_last_work);
if (days_since_work > 64) {
m_g_last_work = aipGood;
} else if (days_since_work > 32) {
m_g_last_work = aipQuiteGood;
} else if (days_since_work > 16) {
m_g_last_work = aipPrettyGood;
} else if (days_since_work > 8) {
m_g_last_work = aipFairlyGood;
} else if (days_since_work > 4) {
m_g_last_work = aipSomewhatGood;
} else if (days_since_work > 2) {
m_g_last_work = aipSlightlyGood;
}
}
}
//----------------------------------------------------------------------
// Note that a decision involving this employee has been decided
// void rpsEmployee::note_rps_decide (rpsDecision *d, rpsOption *o) { }
//----------------------------------------------------------------------
// empday_iterator
rpsEmpDayItr rpsEmployee::empday_iterator() const {
rpsEmpDayItr i(resday_pandemonium());
return i;
}
//======================================================================
// rpsEmpDay
//
//----------------------------------------------------------------------
// constructor
rpsEmpDay::rpsEmpDay(rpsEmployee *a_emp, long a_yyyymmdd,
long a_start_hhmm, long a_end_hhmm)
: aiprrResDay(a_emp, a_yyyymmdd) {
m_start_time = aipTime(a_yyyymmdd, a_start_hhmm);
m_end_time = aipTime(a_yyyymmdd, a_end_hhmm);
m_yyyymmdd = a_yyyymmdd;
// if empday crosses midnight...
if (m_end_time < m_start_time) m_end_time.add_days(1);
}
//----------------------------------------------------------------------
// take_msg - take and react to a message
void rpsEmpDay::take_msg (aipMsg *mm) {
aiprrResDay::take_msg(mm);
// rpsMsg *m = (rpsMsg *)mm;
// if (m->typ() == HH_Starting_New_Try) {
// }
}
//----------------------------------------------------------------------
// Note that a decision involving this empday has been decided
// void rpsEmpDay::note_rps_decide (rpsDecision *d, rpsOption *o) { }
//----------------------------------------------------------------------
// opt_iterator - return an iterator: options for an EmpDay
rpsOptItr rpsEmpDay::opt_iterator() const {
rpsOptItr i(opt_pandemonium());
return i;
}
//======================================================================
// Iterators
//
// All function bodies in header file.
//
//======================================================================
// License
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to
// whom the Software is furnished to do so, subject to the
// following conditions:
//
// The copyright notice and this license shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
//======================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -