Rev 905 |
Rev 907 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include <QList>
#include "activity.h"
class Expression;
namespace AMIE {
class FMStand; // forward
class FMUnit; // forward
/** @brief SchedulerOptions store agent-specific options.
* */
struct SchedulerOptions {
SchedulerOptions(): useScheduler(false), minScheduleHarvest(0), maxScheduleHarvest(0), maxHarvestOvershoot(0), scheduleRebounceDuration(0) { minRating = 0; }
~SchedulerOptions();
bool useScheduler; ///< true, if scheduler used by agent
double minScheduleHarvest; ///< minimum amount of m3/ha*yr that should be scheduled
double maxScheduleHarvest; ///< the maximum number of m3/ha*yr that should be scheduled
double maxHarvestOvershoot; ///< multiplier to define the maximum overshoot over the planned volume (e.g. 1.2 -> 20% max. overshoot)
double scheduleRebounceDuration; ///< number of years for which deviations from the planned volume are split into
Expression *minRating; ///< formula to determine the minimum required activity rating for a given amount of harvest objective achievment.
void setup(QJSValue jsvalue);
};
/**
* @brief The Scheduler class schedules the forest management activities
* on a planning unit.
*
*/
class Scheduler
{
public:
Scheduler(FMUnit* unit) { mUnit = unit; }
/// add an planned activity for a given stand.
/// @param stand the stand to add
/// @param flags the execution flags (activty x stand)
/// @param prob_schedule the probability from the activity-scheduling algorithm at the time of adding the ticket
/// @param prob_execute the probability for executing the activity (based on the constraints of the activity)
void addTicket(FMStand *stand, ActivityFlags *flags, double prob_schedule, double prob_execute);
/// executes the scheduler for the planning unit.
/// scheduled operations are executed.
void run();
/// prepone a stand if in queue
bool forceHarvest(const FMStand *stand, const int max_years);
/// get current score for stand 'id'
/// return -1 if stand is invalid, 0..1 for probabilities, 1.1 for forced execution
double scoreOf(const int stand_id) const;
QStringList info(const int stand_id) const;
private:
class SchedulerItem {
public:
SchedulerItem(): stand(0), score(0.) {}
bool operator<(const SchedulerItem &item);
void calculate(); ///< calculate the final score
FMStand *stand; ///< the stand to be harvested
double harvest; ///< the scheduled harvest in m3
double harvestPerHa; ///< harvest per ha
double scheduleScore; ///< the probability based on schedule timing
double harvestScore; ///< the probability of the activity
double score; ///< the total score of this ticked to be executed this year
enum HarvestType { Thinning, EndHarvest} harvestType; ///< type of harvest
int enterYear; ///< the year the ticket was created
int optimalYear; ///< the (first) year where execution is considered as optimal
int forbiddenTo; ///< year until which the harvest operation is forbidden
ActivityFlags *flags; ///< the details of the activity/stand context
};
QList<SchedulerItem*> mItems; ///< the list of active tickets
/// find scheduler item for 'stand_id' or return NULL.
SchedulerItem* item(const int stand_id) const;
FMUnit *mUnit;
};
} // namespace
#endif // SCHEDULER_H