forked from anubhav-gres/VAL-4.2.08
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaTeXSupport.cpp
More file actions
264 lines (218 loc) · 9.3 KB
/
LaTeXSupport.cpp
File metadata and controls
264 lines (218 loc) · 9.3 KB
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
/************************************************************************
* Copyright 2008, Strathclyde Planning Group,
* Department of Computer and Information Sciences,
* University of Strathclyde, Glasgow, UK
* http://planning.cis.strath.ac.uk/
*
* Maria Fox, Richard Howey and Derek Long - VAL
* Stephen Cresswell - PDDL Parser
*
* This file is part of VAL, the PDDL validator.
*
* VAL is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* VAL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAL. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/
/*-----------------------------------------------------------------------------
VAL - The Automatic Plan Validator for PDDL+
$Date: 2009-02-05 10:50:20 $
$Revision: 1.2 $
Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL
Stephen Cresswell - PDDL Parser
maria.fox@cis.strath.ac.uk
derek.long@cis.strath.ac.uk
stephen.cresswell@cis.strath.ac.uk
richard.howey@cis.strath.ac.uk
By releasing this code we imply no warranty as to its reliability
and its use is entirely at your own risk.
Strathclyde Planning Group
http://planning.cis.strath.ac.uk
----------------------------------------------------------------------------*/
#include "LaTeXSupport.h"
#include "ptree.h"
namespace VAL {
extern analysis an_analysis;
LaTeXSupport latex;
void displayFailedLaTeXList(vector<string> & vs)
{
string s;
for(vector<string>::const_iterator i = vs.begin(); i != vs.end() ; )
{
s = *i; replaceSubStrings(s,"/","/\\-"); latexString(s);
*report << "\\begin{minipage}[t]{13cm} " << s << " \\end{minipage}";
if( ++i != vs.end()) *report << "\\\\";
*report << "\n";
};
};
void LaTeXSupport::LaTeXBuildGraph(ActiveCtsEffects * ace,const State * s)
{
for(map<const FuncExp *,ActiveFE*>::const_iterator fe = ace->activeFEs.begin();
fe != ace->activeFEs.end();++fe)
{
FEGraph * feg = s->getValidator()->getGraph(fe->first);
double intEndTime = s->getTime(); //time at start of interval
feg->happenings.insert(intEndTime - ace->localUpdateTime);
feg->happenings.insert(intEndTime);
//setup initial value if nec, must be already to update cts so can assume defined in prob file here
if(feg->initialTime == -1)
{
feg->initialTime = 0;
feg->initialValue = fe->first->evaluate(s);
};
if( (fe->second)->isLinear())
{
feg->points[intEndTime - ace->localUpdateTime] = fe->second->evaluate(0);
feg->points[intEndTime] = fe->second->evaluate(ace->localUpdateTime);
}
else
{
//number dividing is the number of points across whole interval if all cts
double stepLength = s->getValidator()->getMaxTime() / NoGraphPoints;
if(const NumericalSolution * ns = dynamic_cast<const NumericalSolution *>(fe->second->ctsFtn))
{ map<double,CoScalar> thePoints = ns->getPoints();
map<double,CoScalar>::const_iterator j = thePoints.begin();
feg->points[intEndTime - ace->localUpdateTime + j->first] = j->second;
CoScalar lastPoint = j->first;
++j;
for(map<double,CoScalar>::const_iterator j = thePoints.begin(); j != thePoints.end(); ++j)
{
if(j->first > ace->localUpdateTime) break;
if(j->first - lastPoint >= stepLength)
{
feg->points[intEndTime - ace->localUpdateTime + j->first] = j->second;
lastPoint = j->first;
};
};
}
else
{
for(double t = 0; t < ace->localUpdateTime; t += stepLength)
{
feg->points[intEndTime - ace->localUpdateTime + t] = fe->second->evaluate(t);
};
};
feg->points[intEndTime] = fe->second->evaluate(ace->localUpdateTime);
};
};
};
void LaTeXSupport::LaTeXHeader()
{
*report << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"
<< "% %\n"
<< "% Plan Validation Report Generated by VAL %\n"
<< "% %\n"
<< "% Strathclyde Planning Group %\n"
<< "% %\n"
<< "% %\n"
<< "% Comments on Report to %\n"
<< "% richard.howey@cis.strath.ac.uk %\n"
<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"
<< "\\documentclass[a4paper,12pt]{article}\n"
<< "\\usepackage{rotating,color,morefloats}\n"
<< "\\newcommand{\\headingtimeaction}{{\\bf Time} \\qquad \\= {\\bf Action}\\\\[0.8ex]}\n"
<< "\\newcommand{\\headingtimehappening}{{\\bf Time} \\qquad \\= {\\bf Happening}\\\\[0.8ex]}\n"
<< "\\newcommand{\\headingtimedetails}{{\\bf Time} \\qquad \\= {\\bf Details}\\\\[0.8ex]}\n"
<< "\\newcommand{\\atime}[1]{{\\bf #1:}}\n"
<< "\\newcommand{\\action}[1]{{\\sf #1}}\n"
<< "\\newcommand{\\exprn}[1]{{\\sf #1}}\n"
<< "\\newcommand{\\fexprn}[1]{{\\small {\\bf #1}}}\n"
<< "\\newcommand{\\condeffmon}[1]{#1 {\\it - conditional effect monitor}}\n"
<< "\\newcommand{\\updatectspne}{{\\it Update of changing Primitive Numerical Expressions}}\n"
<< "\\newcommand{\\actionstart}[1]{#1 {\\it - start}}\n"
<< "\\newcommand{\\actionend}[1]{#1 {\\it - end}}\n"
<< "\\newcommand{\\actioninv}[1]{{\\it Invariant for } #1}\n"
<< "\\newcommand{\\checkhappening}{Checking Happening... }\n"
<< "\\newcommand{\\eventtriggered}{{\\bf Event triggered!}}\n"
<< "\\newcommand{\\listrow}[1]{\\begin{minipage}[t]{11.5cm} #1 \\end{minipage}}\n"
<< "\\newcommand{\\listrowg}[1]{\\begin{minipage}[t]{10cm} #1 \\end{minipage}}\n"
<< "\\newcommand{\\happeningOK}{...OK!}\n"
<< "\\newcommand{\\notOK}{...NOT OK!}\n"
<< "\\newcommand{\\aprocessactivated}[1]{\\listrow{{\\it Activated process #1} }}\n"
<< "\\newcommand{\\aprocessunactivated}[1]{\\listrow{{\\it Unactivated process #1} }}\n"
<< "\\newcommand{\\aeventtriggered}[1]{\\listrow{{\\it Triggered event #1} }}\n"
<< "\\newcommand{\\assignment}[3]{\\listrow{Updating \\fexprn{#1} (#2) by #3 assignment.}}\n"
<< "\\newcommand{\\assignmentcts}[3]{\\listrow{Updating \\fexprn{#1} (#2) by #3 for continuous update.}}\n"
<< "\\newcommand{\\increase}[3]{\\listrow{Increasing \\fexprn{#1} (#2) by #3.}}\n"
<< "\\newcommand{\\decrease}[3]{\\listrow{Decreasing \\fexprn{#1} (#2) by #3.}}\n"
<< "\\newcommand{\\scaleup}[3]{\\listrow{Scaling up \\fexprn{#1} (#2) by a factor of #3.}}\n"
<< "\\newcommand{\\scaledown}[3]{\\listrow{Scaling down \\fexprn{#1} (#2) by a factor of #3.}}\n"
<< "\\newcommand{\\function}[2]{\\listrow{\\fexprn{#1}$(t) = #2$}}\n"
<< "\\newcommand{\\adding}[1]{\\listrow{Adding \\exprn{#1} }}\n"
<< "\\newcommand{\\deleting}[1]{\\listrow{Deleting \\exprn{#1} }}\n"
<< "\\newcommand{\\error}{...Error!\\\\}\n"
<< "\\newcommand{\\errorr}[1]{...Error! \\\\ \\> #1}\n"
<< "\\renewcommand{\\thefigure}{\\arabic{section}.\\arabic{figure}}"
<< "\\title{Plan Validation Report}\n"
<< "\\author{\\mbox{\\sc {\\sc Val}}}\n"
<< "\\begin{document}\n \\maketitle \n";
};
void LaTeXSupport::LaTeXDomainAndProblem()
{
string d = current_analysis->the_domain->name;
latexString(d);
string p = current_analysis->the_problem->name ;
latexString(p);
*report << "\\section{Domain and Problem}\n";
*report << "{\\bf Domain:} "<< d <<"\\\\\n";
*report << "{\\bf Problem:} "<< p <<"\n";
};
void LaTeXSupport::LaTeXPlanReport(Validator * v,plan * the_plan)
{
*report << "\\subsection{Plan}\n";
v->displayInitPlanLaTeX(the_plan);
*report << "\\subsection{Plan To Validate}\n";
v->displayPlan();
*report << "\\subsection{Plan Validation}\n";
};
void LaTeXSupport::LaTeXGantt(Validator * v)
{
pddl_type* type;
//setup Gantt chart objects to be tracked (coloured)
for(vector<string>::iterator go = ganttObjectsAndTypes.begin(); go != ganttObjectsAndTypes.end(); ++go)
{
type = current_analysis->pddl_type_tab.symbol_probe(*go);
if(type != NULL)
{
for(typed_symbol_list<const_symbol>::const_iterator o = current_analysis->the_problem->objects->begin();
o != current_analysis->the_problem->objects->end() ; ++o)
{
if((*o)->type == type) ganttObjects.push_back((*o)->getName());
};
}
else
{
ganttObjects.push_back(*go);
};
};
v->setSigObjs(ganttObjects);
*report << "\\subsection{Gantt Chart}\n";
v->drawLaTeXGantt(noGCPages,noGCPageRows);
};
void LaTeXSupport::LaTeXGraphs(Validator * v)
{
*report << "\\subsection{Primitive Numerical Expression Graphs}\n";
*report << "\\setcounter{figure}{0}\n";
v->displayLaTeXGraphs();
};
void LaTeXSupport::LaTeXPlanReportPrepare(char * pnm)
{
string planName(pnm);
replaceSubStrings(planName,"/","/\\-");
latexString(planName);
*report << "\\section{\\sloppy Plan: "<< planName <<"}\n";
};
void LaTeXSupport::LaTeXEnd()
{
*report << "\\end{document}\n";
};
};