/usr/include/gecode/int/task.hh is in libgecode-dev 3.7.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2009
*
* Last modified:
* $Date: 2011-07-12 18:03:22 +0200 (Tue, 12 Jul 2011) $ by $Author: tack $
* $Revision: 12176 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* 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 above copyright notice and this permission notice 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
* NONINFRINGEMENT. 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.
*
*/
#ifndef __GECODE_INT_TASK_HH__
#define __GECODE_INT_TASK_HH__
#include <gecode/int.hh>
namespace Gecode { namespace Int {
/// Class to define an optional from a mandatory task
template<class ManTask>
class ManToOptTask : public ManTask {
protected:
/// Boolean view whether task is mandatory (= 1) or not
Int::BoolView _m;
public:
/// \name Constructors and initialization
//@{
/// Default constructor
ManToOptTask(void);
//@}
/// \name Value access
//@{
/// Whether task is mandatory
bool mandatory(void) const;
/// Whether task is excluded
bool excluded(void) const;
/// Whether task can still be optional
bool optional(void) const;
//@}
//@{
/// Test whether task is assigned
bool assigned(void) const;
//@}
/// \name Value update
//@{
/// Mark task as mandatory
ModEvent mandatory(Space& home);
/// Mark task as excluded
ModEvent excluded(Space& home);
//@}
/// \name Cloning
//@{
/// Update this task to be a clone of task \a t
void update(Space& home, bool share, ManToOptTask& t);
//@}
/// \name Dependencies
//@{
/// Subscribe propagator \a p to task
void subscribe(Space& home, Propagator& p, PropCond pc);
/// Cancel subscription of propagator \a p for task
void cancel(Space& home, Propagator& p, PropCond pc);
//@}
};
}}
#include <gecode/int/task/man-to-opt.hpp>
namespace Gecode { namespace Int {
/// Task mapper: turns a task view into its dual
template<class TaskView>
class FwdToBwd : public TaskView {
public:
/// \name Value access
//@{
/// Return earliest start time
int est(void) const;
/// Return earliest completion time
int ect(void) const;
/// Return latest start time
int lst(void) const;
/// Return latest completion time
int lct(void) const;
/// Return minimum processing time
int pmin(void) const;
/// Return maximum processing time
int pmax(void) const;
//@}
/// \name Value update
//@{
/// Update earliest start time to \a n
ModEvent est(Space& home, int n);
/// Update earliest completion time to \a n
ModEvent ect(Space& home, int n);
/// Update latest start time to \a n
ModEvent lst(Space& home, int n);
/// Update latest completion time to \a n
ModEvent lct(Space& home, int n);
/// Update such that task cannot run from \a e to \a l
ModEvent norun(Space& home, int e, int l);
//@}
};
}}
#include <gecode/int/task/fwd-to-bwd.hpp>
namespace Gecode { namespace Int {
/**
* \brief Traits class for mapping task views to tasks
*
* Each task view must specialize this traits class and add a \code
* typedef \endcode for the task corresponding to this task view.
*/
template<class TaskView>
class TaskViewTraits {};
/**
* \brief Traits class for mapping tasks to task views
*
* Each task must specialize this traits class and add \code
* typedef \endcode for the task views corresponding to this task.
*/
template<class Task>
class TaskTraits {};
}}
namespace Gecode { namespace Int {
/// Task array
template<class Task>
class TaskArray {
private:
/// Number of tasks (size)
int n;
/// Tasks
Task* t;
public:
/// \name Constructors and initialization
//@{
/// Default constructor (array of size 0)
TaskArray(void);
/// Allocate memory for \a n tasks (no initialization)
TaskArray(Space& home, int n);
/// Initialize from task array \a a (share elements)
TaskArray(const TaskArray<Task>& a);
/// Initialize from task array \a a (share elements)
const TaskArray<Task>& operator =(const TaskArray<Task>& a);
//@}
/// \name Array size
//@{
/// Return size of array (number of elements)
int size(void) const;
/// Set size of array (number of elements) to \a n, must not be larger
void size(int n);
//@}
/// \name Array elements
//@{
/// Return task at position \a i
Task& operator [](int i);
/// Return task at position \a i
const Task& operator [](int i) const;
//@}
/// \name Dependencies
//@{
/// Subscribe propagator \a p to all tasks
void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
/// Cancel subscription of propagator \a p for all tasks
void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
//@}
/// \name Cloning
//@{
/// Update array to be a clone of array \a a
void update(Space&, bool share, TaskArray& a);
//@}
private:
static void* operator new(size_t);
static void operator delete(void*,size_t);
};
/**
* \brief Print array elements enclosed in curly brackets
* \relates TaskArray
*/
template<class Char, class Traits, class Task>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os,
const TaskArray<Task>& t);
/// Task view array
template<class TaskView>
class TaskViewArray {
protected:
/// The underlying task type
typedef typename TaskViewTraits<TaskView>::Task Task;
/// Access to task array
TaskArray<Task>& t;
public:
/// \name Constructors and initialization
//@{
/// Initialize from task array \a a
TaskViewArray(TaskArray<Task>& t);
//@}
/// \name Array information
//@{
/// Return size of array (number of elements)
int size(void) const;
/// Set size of array (number of elements) to \a n, must not be larger
void size(int n);
//@}
/// \name Array elements
//@{
/// Return task view at position \a i
TaskView& operator [](int i);
/// Return task view at position \a i
const TaskView& operator [](int i) const;
//@}
private:
static void* operator new(size_t);
static void operator delete(void*,size_t);
};
/**
* \brief Print array elements enclosed in curly brackets
* \relates TaskViewArray
*/
template<class Char, class Traits, class TaskView>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os,
const TaskViewArray<TaskView>& t);
}}
#include <gecode/int/task/array.hpp>
namespace Gecode { namespace Int {
/// How to sort tasks
enum SortTaskOrder {
STO_EST, ///< Sort by earliest start times
STO_ECT, ///< Sort by earliest completion times
STO_LST, ///< Sort by latest start times
STO_LCT ///< Sort by latest completion times
};
/// Sort task view array \a t according to \a sto and \a inc (increasing or decreasing)
template<class TaskView, SortTaskOrder sto, bool inc>
void sort(TaskViewArray<TaskView>& t);
/// Initialize and sort \a map for task view array \a t according to \a sto and \a inc (increasing or decreasing)
template<class TaskView, SortTaskOrder sto, bool inc>
void sort(int* map, const TaskViewArray<TaskView>& t);
/// Sort \a map with size \a n for task view array \a t according to \a sto and \a inc (increasing or decreasing)
template<class TaskView, SortTaskOrder sto, bool inc>
void sort(int* map, int n, const TaskViewArray<TaskView>& t);
}}
#include <gecode/int/task/sort.hpp>
namespace Gecode { namespace Int {
/// Allows to iterate over task views according to a specified order
template<class TaskView, SortTaskOrder sto, bool inc>
class TaskViewIter {
protected:
/// Map for iteration order
int* map;
/// Current position
int i;
/// Default constructor (no initialization)
TaskViewIter(void);
public:
/// Initialize iterator
TaskViewIter(Region& r, const TaskViewArray<TaskView>& t);
/// \name Iteration control
//@{
/// Test whether iterator is still at a task
bool operator ()(void) const;
/// How many tasks are left to be iterated
int left(void) const;
/// Move iterator to next task
void operator ++(void);
//@}
/// \name %Task access
//@{
/// Return current task position
int task(void) const;
//@}
};
/// Allows to iterate over mandatory task views according to a specified order
template<class OptTaskView, SortTaskOrder sto, bool inc>
class ManTaskViewIter : public TaskViewIter<OptTaskView,sto,inc> {
protected:
using TaskViewIter<OptTaskView,sto,inc>::map;
using TaskViewIter<OptTaskView,sto,inc>::i;
public:
/// Initialize iterator with mandatory tasks
ManTaskViewIter(Region& r, const TaskViewArray<OptTaskView>& t);
};
}}
#include <gecode/int/task/iter.hpp>
namespace Gecode { namespace Int {
/// Safe addition in case \a x is -Int::Limits::infinity
int plus(int x, int y);
/// Safe addition in case \a x is -Int::Limits::double_infinity
double plus(double x, double y);
/// Safe division in case \a x is -Int::Limits::double_infinity
double div(double x, double y);
/// Task trees for task views with node type \a Node
template<class TaskView, class Node>
class TaskTree {
template<class,class> friend class TaskTree;
protected:
/// The tasks from which the tree is computed
const TaskViewArray<TaskView>& tasks;
/// Task nodes
Node* node;
/// Map task number to leaf node number in right order
int* _leaf;
/// Return number of inner nodes
int n_inner(void) const;
/// Return number of nodes for balanced binary tree
int n_nodes(void) const;
/// Whether node \a i is index of root
static bool n_root(int i);
/// Whether node \a i is leaf
bool n_leaf(int i) const;
/// Return index of left child of node \a i
static int n_left(int i);
/// Test whether node \a i is a left child
static bool left(int i);
/// Return index of right child of node \a i
static int n_right(int i);
/// Test whether node \a i is a right child
static bool right(int i);
/// Return index of parent of node \a i
static int n_parent(int i);
protected:
/// Return leaf for task \a i
Node& leaf(int i);
/// Return root node
const Node& root(void) const;
/// Update tree after leaf for task \a i has changed (\a l whether i refers to a leaf)
void update(int i, bool l=true);
/// Initialize tree after leaves have been initialized
void init(void);
/// Update all inner nodes of tree after leaves have been initialized
void update(void);
/// Initialize tree for tasks \a t
TaskTree(Region& r, const TaskViewArray<TaskView>& t);
/// Initialize tree using tree \a t
template<class Node2> TaskTree(Region& r,
const TaskTree<TaskView,Node2>& t);
};
}}
#include <gecode/int/task/tree.hpp>
namespace Gecode { namespace Int {
/**
* \brief %Propagator for tasks
*
* Requires \code #include <gecode/int/task.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Task, PropCond pc>
class TaskProp : public Propagator {
protected:
/// Tasks
TaskArray<Task> t;
/// Constructor for creation
TaskProp(Home home, TaskArray<Task>& t);
/// Constructor for cloning \a p
TaskProp(Space& home, bool shared, TaskProp<Task,pc>& p);
public:
/// Cost function (defined as high linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/// Purge optional tasks that are excluded and possibly rewrite propagator
template<class OptTask,PropCond pc>
ExecStatus purge(Space& home, Propagator& p, TaskArray<OptTask>& t);
/// Purge optional tasks that are excluded and possibly rewrite propagator
template<class OptTask,PropCond pc,class Cap>
ExecStatus purge(Space& home, Propagator& p, TaskArray<OptTask>& t, Cap c);
}}
#include <gecode/int/task/prop.hpp>
#include <gecode/int/task/purge.hpp>
#endif
// STATISTICS: scheduling-prop
|