Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
options.cpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Christian Schulte <schulte@gecode.org>
5 *
6 * Copyright:
7 * Christian Schulte, 2008
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#include <gecode/search.hh>
35
36#include <cmath>
37
38namespace Gecode { namespace Search {
39
40 const Options Options::def;
41
42 Options
43 Options::expand(void) const {
44#ifdef GECODE_HAS_THREADS
45 double t = threads;
46 if (t <= -1.0) {
48 } else if (t < 0.0) {
49 t = (1.0 + t) * Support::Thread::npu();
50 } else if (t == 0.0) {
52 } else if (t < 1.0) {
54 }
55 t = floor(t+0.5);
56 if (t < 1.0)
57 t = 1.0;
58 Options o(*this);
59 o.threads = t;
60 return o;
61#else
62 return *this;
63#endif
64 }
65
66}}
67
68// STATISTICS: search-other
NodeType t
Type of node.
Search engine options
Definition search.hh:746
static const Options def
Default options.
Definition search.hh:771
Options expand(void) const
Expand with real number of threads.
Definition options.cpp:43
double threads
Number of threads to use.
Definition search.hh:751
static unsigned int npu(void)
Return number of processing units (1 if information not available)
Definition none.hpp:76
Gecode toplevel namespace