Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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 * 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 <cstdlib>
35#include <QtGui>
36
37#include <gecode/gist.hh>
41
42namespace Gecode { namespace Gist {
43
44 std::string
45 Inspector::name(void) { return "Inspector"; }
46
47 void
49
51
52 std::string
53 Comparator::name(void) { return "Comparator"; }
54
55 void
57
59
60 TextOutput::TextOutput(const std::string& name)
61 : t(NULL), n(name) {}
62
63 void
65 delete t;
66 t = NULL;
67 }
68
70 delete t;
71 }
72
73 std::string
74 TextOutput::name(void) { return n; }
75
76 void
78 if (t == NULL) {
79 t = new TextOutputI(n);
80 }
81 t->setVisible(true);
82 }
83
84 std::ostream&
86 return t->getStream();
87 }
88
89 void
91 t->flush();
92 }
93
94 void
95 TextOutput::addHtml(const char* s) {
96 t->insertHtml(s);
97 }
98
100
101 int
102 explore(Space* root, bool bab, const Options& opt) {
103
104#ifdef _MSC_VER
105 // Set the plugin search path on Windows when in default installation
106 if (char* gd = getenv("GECODEDIR")) {
107 unsigned int gdl = static_cast<unsigned int>(strlen(gd) + 32U);
108 char* gdb = heap.alloc<char>(gdl);
109 strcpy(gdb, gd);
110 strcat(gdb, "/bin/");
111 QCoreApplication::addLibraryPath(gdb);
112 heap.free(gdb,gdl);
113 }
114#endif
115
116 char argv0='\0'; char* argv1=&argv0;
117 int argc=0;
118
119
120 QApplication app(argc, &argv1);
121
122 GistMainWindow mw(root, bab, opt);
123 return app.exec();
124 }
125
126 void
128 StopBrancher::post(home);
129 }
130
131}}
132
133// STATISTICS: gist-any
NodeType t
Type of node.
int n
Number of negative literals for node type.
virtual std::string name(void)
Name of the comparator.
Definition gist.cpp:53
virtual void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:56
virtual ~Comparator(void)
Destructor.
Definition gist.cpp:58
Main window for stand-alone Gist.
Definition mainwindow.hh:54
virtual void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:48
virtual ~Inspector(void)
Destructor.
Definition gist.cpp:50
virtual std::string name(void)
Name of the inspector.
Definition gist.cpp:45
Options for Gist
Definition gist.hh:234
static const Options def
Default options.
Definition gist.hh:269
static void post(Home home)
Post brancher.
Window with associated ostream, used for inspecting Gist nodes.
Definition textoutput.hh:42
void flush(void)
Flush output.
void insertHtml(const QString &s)
Add html string s to the output.
std::ostream & getStream(void)
Return stream that prints to the text display.
void finalize(void)
Clean up when Gist exits.
Definition gist.cpp:64
void flush(void)
Flush stream.
Definition gist.cpp:90
virtual ~TextOutput(void)
Destructor.
Definition gist.cpp:69
TextOutput(const std::string &name)
Constructor.
Definition gist.cpp:60
std::ostream & getStream(void)
Get the stream that is used to output text.
Definition gist.cpp:85
virtual std::string name(void)
Name of the inspector.
Definition gist.cpp:74
void init(void)
Initialize the implementation object.
Definition gist.cpp:77
void addHtml(const char *s)
Add html text s to the output.
Definition gist.cpp:95
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Definition heap.hpp:457
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
Definition heap.hpp:431
Computation spaces.
Definition core.hpp:1742
Heap heap
The single global heap.
Definition heap.cpp:44
int bab(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for branch-and-bound search of root.
Definition gist.hpp:208
int explore(Space *root, bool bab, const Options &opt)
Create a new stand-alone Gist for root using bab.
Definition gist.cpp:102
void stopBranch(Space &home)
A branching that stops exploration.
Definition gist.cpp:127
Gecode toplevel namespace