-
Notifications
You must be signed in to change notification settings - Fork 3
/
DMGA_1.php
311 lines (261 loc) · 8.24 KB
/
DMGA_1.php
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
<?php
/*
* DMGA_1.php
*
* A place to start entering submission parameters for the DMGA analysis
*
*/
include_once 'checkinstance.php';
elogrs( __FILE__ );
if ( ($_SESSION['userlevel'] != 2) &&
($_SESSION['userlevel'] != 3) &&
($_SESSION['userlevel'] != 4) &&
($_SESSION['userlevel'] != 5) ) // only data analyst and up
{
header('Location: index.php');
exit();
}
// Verify that job submission is ok now
include 'lib/motd.php';
if ( motd_isblocked() && ($_SESSION['userlevel'] < 4) )
{
header("Location: index.php");
exit();
}
// Verify that there is something in the queue
if ( ! isset( $_SESSION['request'] ) || sizeof( $_SESSION['request'] ) < 1 )
{
header("Location: queue_setup_1.php");
exit();
}
// define( 'DEBUG', true );
include 'config.php';
include 'db.php';
include 'lib/utility.php';
include 'lib/payload_manager.php';
include 'lib/controls.php';
// Make sure the advancement level is set
$advanceLevel = ( isset($_SESSION['advancelevel']) )
? $_SESSION['advancelevel'] : 0;
$separate_datasets = ( isset( $_SESSION['separate_datasets'] ) )
? $_SESSION['separate_datasets'] : 1;
$advanced_review = ( isset( $_SESSION['advanced_review'] ) )
? $_SESSION['advanced_review'] : 0;
// To support multiple datasets, let's keep track of which one we're on
$num_datasets = sizeof( $_SESSION['request'] );
// Verify no composite job(s) with DMGA
if ( $separate_datasets == 1 && $num_datasets > 1 )
{
header("Location: queue_setup_1.php");
exit();
}
// Create the payload manager
$payload = new Payload_DMGA( $_SESSION );
// Now let's see if the "last"/"TIGRE" button has been pressed
//if ( isset($_POST['last']) ||
// isset($_POST['TIGRE']) )
if ( isset($_POST['TIGRE']) )
{
//$dataset_id = ( $_POST['dataset_id'] < $num_datasets - 1 )
// ? $_POST['dataset_id'] : $num_datasets - 1;
$dataset_id = $num_datasets - 1;
// Save cluster information
if ( isset($_POST['cluster']) )
{
list( $cluster_name, $cluster_shortname, $queue ) = explode(":", $_POST['cluster'] );
$gwhostid = 'uslims3';
if ( isset( $_SESSION[ 'gwhostid' ] ) )
$gwhostid = $_SESSION[ 'gwhostid' ];
list( $cluster_name, $cluster_shortname, $queue ) = explode(":", $_POST['cluster'] );
if ( preg_match( "/alamo/", $gwhostid ) && $cluster_shortname == 'alamo' )
{ // alamo-to-alamo uses alamo-local as cluster
$cluster_shortname = 'alamo-local';
}
$_SESSION['cluster'] = array();
$_SESSION['cluster']['name'] = $cluster_name;
$_SESSION['cluster']['shortname'] = $cluster_shortname;
if ( $cluster_shortname == 'jacinto' )
{
if ( isset($_SESSION['separate_datasets']) )
{
if ( $_SESSION['separate_datasets'] == 0 )
{
$queue = 'ngenseq';
}
}
if ( $separate_datasets == 0 )
{
$queue = 'ngenseq';
}
}
$_SESSION['cluster']['queue'] = $queue;
}
if ( $num_datasets > 1 && $advanced_review == 0 )
{ // For multiple datasets and no advanced review, create all payloads
$payload->clear();
for ( $jdataset_id = 0; $jdataset_id < ( $num_datasets - 1 ); $jdataset_id++ )
{
$payload->acquirePostedData( $jdataset_id, $num_datasets );
}
$payload->save();
}
// get previous payload data and add this session to it
$payload->restore();
$payload->add( 'cluster', $_SESSION['cluster'] );
$payload->acquirePostedData( $dataset_id, $num_datasets );
$payload->save();
header( "Location: DMGA_2.php" );
exit();
}
// Now let's see if the "next" button has been pressed
else if ( isset($_POST['next']) )
{
$dataset_id = ( $_POST['dataset_id'] < $num_datasets - 1 )
? $_POST['dataset_id'] : $num_datasets - 1;
// get previous payload data and add this session to it
$payload->restore();
$payload->acquirePostedData( $dataset_id, $num_datasets );
$payload->save();
$dataset_id++;
}
// In this case it's the first time here
else
{
$dataset_id = 0;
// Add the initial options to the payload
$payload->clear();
$payload->save();
// If multi-data and no advanced review, point to last dataset
if ( $advanced_review == 0 &&
$num_datasets > 1 )
$dataset_id = $num_datasets - 1;
}
// Start displaying page
$page_title = 'Discrete Model GA Analysis';
$css = 'css/slider.css';
$js = 'js/analysis.js,js/DMGA.js';
include 'header.php';
$new_noise = '';
if ( isset($_SESSION['edit_select_type']) &&
$_SESSION['edit_select_type'] == 0 )
{ // If latest edits and noise, reset the noises
set_latest_noises( $link );
$new_noise = $_SESSION['new_noise'];
}
?>
<!-- Begin page content -->
<div id='content'>
<h1 class="title"><?php echo $page_title; ?></h1>
<!-- Place page content here -->
<?php echo $new_noise; ?>
<div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
onsubmit="return validate(this,
<?php echo $advanceLevel; ?>,
<?php echo $dataset_id; ?>,
<?php echo $num_datasets; ?>,
<?php echo $separate_datasets; ?>);" >
<?php
// if ( isset($error) ) echo $error;
$max_dset_id = $num_datasets - 1;
$dataset_id = ( $dataset_id < $num_datasets ) ? $dataset_id : $max_dset_id;
$display_dsid = ( $advanced_review == 0 ) ? 0 : $dataset_id;
display( $display_dsid, $num_datasets );
// Display some information about the current dataset
echo " <fieldset>\n" .
" <h3>Dataset control:</h3>\n" .
" <ul>\n" .
" <li>Current dataset number: " . ($dataset_id + 1) . "</li>\n" .
" <li>Run Name: {$_SESSION['request'][$dataset_id]['filename']}</li>\n" .
" <li>Number of datasets: $num_datasets</li>\n" .
" </ul>\n";
// Add some controls to move to the next dataset, if there's more than one
if ( $num_datasets > 1 && $dataset_id < $max_dset_id )
{
echo " <input type='hidden' name='dataset_id' value='$dataset_id' />\n" .
" <input class='submit' type='submit' name='next' value='Next Dataset -->' /></p>\n";
}
echo " </fieldset>\n";
// Add controls to save the last or only dataset
if ( $dataset_id == $max_dset_id )
{
echo '<div id="clusters-nopmg">' . tigre() . '</div>';
echo '<div id="clusters-pmg" style="display:none">' . tigre( true ) . '</div>';
}
?>
</form>
<?php $payload->show(); ?>
</div>
</div>
<?php
include 'footer.php';
exit();
// Function to display controls for one dataset
function display( $dataset_id, $num_datasets )
{
global $link;
// Get edited data profile
$parts = explode( ".", $_SESSION['request'][$dataset_id]['editFilename'] );
$edit_text = $parts[1];
?>
<fieldset>
<legend>Initialize Discrete Genetic Algorithm Parameters -
<?php echo "{$_SESSION['request'][$dataset_id]['filename']}; " .
"Edit profile: $edit_text; " .
"Dataset " . ($dataset_id + 1) . " of $num_datasets";?></legend>
<?php
if ( $dataset_id == 0 )
{
DMGA_select_setup( $link );
montecarlo();
if ( $num_datasets == 1 )
{
PMGC_option();
}
}
?>
<p><button onclick="return toggle('advanced');" id='show'>
Show Advanced Options</button></p>
<div id='advanced' style='display:none'>
<?php
if ( $dataset_id == 0 )
{
// First time only
demes_setup();
genes_setup();
generations_setup();
crossover_percent();
mutation_percent();
plague_percent();
elitism_setup();
migration_rate();
random_seed();
simpoints_input();
band_volume_input();
radial_grid_input();
time_grid_input();
p_grid_setup();
mutate_sigma_setup();
minimize_opt_setup();
debug_option();
}
else
{
// These are displayed each time.
simpoints_input();
band_volume_input();
radial_grid_input();
time_grid_input();
}
echo<<<HTML
</div>
<input class="submit" type="button"
onclick='window.location="queue_setup_2.php"'
value="Edit Profiles"/>
<input class="submit" type="button"
onclick='window.location="queue_setup_1.php"'
value="Change Experiment"/>
</fieldset>
HTML;
}
?>