Generated on Thu Jan 31 2019 20:56:34 for Gecode by doxygen 1.8.15
gist.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2006
8  *
9  * Last modified:
10  * $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
11  * $Revision: 14967 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include <cstdlib>
39 #include <QtGui>
40 
41 #include <gecode/gist.hh>
45 
46 namespace Gecode { namespace Gist {
47 
48  std::string
49  Inspector::name(void) { return "Inspector"; }
50 
51  void
53 
55 
56  std::string
57  Comparator::name(void) { return "Comparator"; }
58 
59  void
61 
63 
64  TextOutput::TextOutput(const std::string& name)
65  : t(NULL), n(name) {}
66 
67  void
69  delete t;
70  t = NULL;
71  }
72 
74  delete t;
75  }
76 
77  std::string
78  TextOutput::name(void) { return n; }
79 
80  void
82  if (t == NULL) {
83  t = new TextOutputI(n);
84  }
85  t->setVisible(true);
86  }
87 
88  std::ostream&
90  return t->getStream();
91  }
92 
93  void
95  t->flush();
96  }
97 
98  void
99  TextOutput::addHtml(const char* s) {
100  t->insertHtml(s);
101  }
102 
103  const Options Options::def;
104 
105  int
106  explore(Space* root, bool bab, const Options& opt) {
107 
108 #ifdef _MSC_VER
109  // Set the plugin search path on Windows when in default installation
110  if (char* gd = getenv("GECODEDIR")) {
111  unsigned int gdl = static_cast<unsigned int>(strlen(gd) + 32U);
112  char* gdb = heap.alloc<char>(gdl);
113  strcpy(gdb, gd);
114  strcat(gdb, "/bin/");
115  QCoreApplication::addLibraryPath(gdb);
116  heap.free(gdb,gdl);
117  }
118 #endif
119 
120  char argv0='\0'; char* argv1=&argv0;
121  int argc=0;
122 
123 
124  QApplication app(argc, &argv1);
125 
126  GistMainWindow mw(root, bab, opt);
127  return app.exec();
128  }
129 
130  void
131  stopBranch(Space& home) {
132  StopBrancher::post(home);
133  }
134 
135 }}
136 
137 // STATISTICS: gist-any
NodeType t
Type of node.
Definition: bool-expr.cpp:234
std::ostream & getStream(void)
Get the stream that is used to output text.
Definition: gist.cpp:89
virtual ~Inspector(void)
Destructor.
Definition: gist.cpp:54
TextOutput(const std::string &name)
Constructor.
Definition: gist.cpp:64
virtual void finalize(void)
Clean up when Gist exits.
Definition: gist.cpp:52
void addHtml(const char *s)
Add html text s to the output.
Definition: gist.cpp:99
void stopBranch(Space &home)
A branching that stops exploration.
Definition: gist.cpp:131
virtual std::string name(void)
Name of the inspector.
Definition: gist.cpp:78
void flush(void)
Flush stream.
Definition: gist.cpp:94
Computation spaces.
Definition: core.hpp:1748
void flush(void)
Flush output.
Definition: textoutput.cpp:152
virtual std::string name(void)
Name of the comparator.
Definition: gist.cpp:57
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
Definition: heap.hpp:435
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Options opt
The options.
Definition: test.cpp:101
Main window for stand-alone Gist.
Definition: mainwindow.hh:58
void finalize(void)
Clean up when Gist exits.
Definition: gist.cpp:68
virtual std::string name(void)
Name of the inspector.
Definition: gist.cpp:49
void init(void)
Initialize the implementation object.
Definition: gist.cpp:81
virtual ~TextOutput(void)
Destructor.
Definition: gist.cpp:73
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Definition: heap.hpp:461
virtual void finalize(void)
Clean up when Gist exits.
Definition: gist.cpp:60
Heap heap
The single global heap.
Definition: heap.cpp:48
int bab(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for branch-and-bound search of root.
Definition: gist.hpp:212
std::ostream & getStream(void)
Return stream that prints to the text display.
Definition: textoutput.cpp:147
static const Options def
Default options.
Definition: gist.hh:273
virtual ~Comparator(void)
Destructor.
Definition: gist.cpp:62
int explore(Space *root, bool bab, const Options &opt)
Create a new stand-alone Gist for root using bab.
Definition: gist.cpp:106
Gecode toplevel namespace
void insertHtml(const QString &s)
Add html string s to the output.
Definition: textoutput.cpp:157
Window with associated ostream, used for inspecting Gist nodes.
Definition: textoutput.hh:46
Options for Gist
Definition: gist.hh:238
static void post(Home home)
Post brancher.