Commit 94cd893c authored by Sumudu Kankanamge's avatar Sumudu Kankanamge 🤔
Browse files

-Added almost all options available in the Dynare documentation for the perfect_foresight command.

-Added help bubbles for options.
-Added a console clear button
-Clean up
-Small fixes.
parent 4e515078
This diff is collapsed.
......@@ -4,7 +4,7 @@ function di_stochastic_simulations()
global M_ options_ oo_
%remove this instruction when proper path is found
addpath jsonlab - 1.5;
addpath jsonlab-1.5;
disp('di_stochastic_simulations performing Matlab tasks');
......@@ -165,7 +165,7 @@ function di_stochastic_simulations()
case 34
options_.loglinear = true;
case 35
options_.dr_display_tol == jm.optionsdescription{nopts}.stooptvalue;
options_.dr_display_tol = jm.optionsdescription{nopts}.stooptvalue;
case 36
options_.contemporaneous_correlation = true;
case 37
......@@ -180,7 +180,9 @@ function di_stochastic_simulations()
try
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);
catch ME
disp(ME)
disp(ME);
runflag=0;
return;
end
if isfield(oo_, 'irfs') == 1
......@@ -200,6 +202,9 @@ function di_stochastic_simulations()
data2json.var_list = oo_.var_list;
end
savejson('', data2json, 'stochsimout.JSON');
if runflag==1
%we only create output JSON if there are no errors
savejson('', data2json, 'stochsimout.JSON');
end
return;
......@@ -340,13 +340,13 @@ module.exports = {
// preparing only the standardized JSON in data
var perfectindata = {
'exonum': perfectval['exonum'],
'simperiods': perfectval['simperiods'],
'permanentshockexist': perfectval['permanentshockexist'],
'transitoryshockexist': perfectval['transitoryshockexist'],
'nonanticipatedshockexist': perfectval['nonanticipatedshockexist'],
'delayexist': perfectval['delayexist'],
'permanentshocksdescription': perfectval['permanentshocksdescription'],
'shocksdescription': perfectval['shocksdescription'],
'optionsdescription':perfectval['optionsdescription'],
'nonanticipmatrix': perfectval['nonanticipmatrix']
};
......
......@@ -175,6 +175,13 @@ $('#savecode').click(function () {
return false;
});
//button clear console
$('#consoleclearbtn').click(function () {
document.getElementById("preprocessorout").value='';
});
//new project on click function
......
......@@ -646,8 +646,6 @@ $('#runestimation').click(async function () {
if ($("#estimopt_id_" + estimoptcounter.toString()).is(':checked')) {
console.log("#estimopt_id_" + estimoptcounter.toString() + " is checked");
if (element.estoptinputtype == 0) { //checking no input options
estoptionsdescription.push({
'estoptindex': parseInt(estimoptcounter, 10),
......@@ -655,7 +653,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': parseInt(element.estoptinputtype, 10),
'estoptvalue': ''
});
console.log(estoptionsdescription);
}
if (element.estoptinputtype == 1) { //checking integer input options
......@@ -687,8 +684,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': parseInt(element.estoptinputtype, 10),
'estoptvalue': parseInt(estimoptval, 10)
});
console.log(estoptionsdescription);
}
......@@ -716,8 +711,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': parseInt(element.estoptinputtype, 10),
'estoptvalue': parseFloat(estimoptval, 10)
});
console.log(estoptionsdescription);
}
......@@ -747,8 +740,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 1,
'estoptvalue': parseInt(estimoptval, 10)
});
console.log(estoptionsdescription);
} else { //if not a number we verify if it is a range or an array of numbers
......@@ -777,7 +768,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 10,
'estoptvalue': '[' + estimoptsplit[0] + ':' + estimoptsplit[1] + ']'
});
console.log(estoptionsdescription);
} else {
$('.nav-tabs a[href="#estimoptions"]').tab('show');
popthis('Options error.', estimoptdyn + ' value is not properly entered.');
......@@ -803,7 +793,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 11,
'estoptvalue': '[' + estimoptval + ']'
});
console.log(estoptionsdescription);
}
} else {
$('.nav-tabs a[href="#estimoptions"]').tab('show');
......@@ -836,7 +825,6 @@ $('#runestimation').click(async function () {
// 'estoptinputtype': 2,
// 'estoptvalue': parseInt(estimoptval, 10)
// });
// console.log(estoptionsdescription);
// } else { //if not a number we verify if it is a range or an array of numbers
......@@ -859,7 +847,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 21,
'estoptvalue': '[' + estimoptval + ']'
});
console.log(estoptionsdescription);
} else {
$('.nav-tabs a[href="#estimoptions"]').tab('show');
......@@ -877,9 +864,6 @@ $('#runestimation').click(async function () {
estimoptval = $("#estimopt_input_" + estimoptcounter.toString() + " option:selected").text();
estimoptdyn = (element.estoptdynarename).bold();
console.log(estimoptindex);
console.log(estimoptval);
if (estimoptindex == null) {
$('.nav-tabs a[href="#estimoptions"]').tab('show');
popthis('Options error.', 'You have activated the ' + estimoptdyn + ' option without selection a value. Please deactivate this option if you are not using it or want to use its default value.');
......@@ -892,8 +876,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 5,
'estoptvalue': estimoptval
});
console.log(estoptionsdescription);
}
......@@ -945,8 +927,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 60,
'estoptvalue': estimoptval
});
console.log(estoptionsdescription);
} else {
if (estimoptval == 'varobs') { //We list all endogenous observables behind the estimation command
......@@ -960,7 +940,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 60,
'estoptvalue': estendolist
});
console.log(estoptionsdescription);
} else {
//we check for a single endogenous entry
......@@ -982,7 +961,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 60,
'estoptvalue': estimoptval
});
console.log(estoptionsdescription);
}
}
......@@ -995,9 +973,6 @@ $('#runestimation').click(async function () {
'estoptinputtype': 60,
'estoptvalue': '(' + estimoptval + ')'
});
console.log(estoptionsdescription);
}
}
}
......@@ -1020,18 +995,14 @@ $('#runestimation').click(async function () {
'estoptinputtype': 60,
'estoptvalue': estendolist
});
console.log(estoptionsdescription);
}
//we post to the server
console.log('Ready to post variables');
//getting the file to be sent
// var formData = new FormData(document.getElementById("estfile").files[0]);
// formData.append("CustomField", "This is some extra data");
var fd = new FormData();
var re = /(?:\.([^.]+))?$/;
......@@ -1039,7 +1010,6 @@ $('#runestimation').click(async function () {
fd.append("filename", $('#codehash').val());
fd.append("filetype", re.exec(document.getElementById('estfile').files[0].name)[1]);
// console.log(fd)
var estimationval = {
'modelhash': $('#codehash').val(),
......@@ -1064,7 +1034,6 @@ $('#runestimation').click(async function () {
document.getElementById('inner').appendChild(div);
$('.nav-tabs a[href="#console"]').tab('show');
console.log(estimationvaldata);
$.ajax({
......@@ -1079,7 +1048,6 @@ $('#runestimation').click(async function () {
contentType: false, // indique à jQuery de ne pas configurer le contentType
success: function (resp) {
console.log(resp);
//if file upload was sucessful we send rest of the data
$.ajax({
......@@ -1093,20 +1061,14 @@ $('#runestimation').click(async function () {
data: estimationvaldata,
success: function (resp) {
// console.log(resp)
if (resp.status == 200) {
console.log("200")
return popthis('Error', resp.message);
} else if (resp.status == 100) {
console.log("100")
showconsolealert(resp.message, 1);
scrolltextarea();
console.log('console error');
return false;
}
console.log('All done here !')
},
error: function (e) {
console.log('there was a problem checking the fields:' + e);
......
This diff is collapsed.
......@@ -39,13 +39,10 @@ $('#setstochastic').click(function () {
success: function (resp) {
if (resp.status == 200) {
console.log("200")
return popthis('Error', resp.message);
} else if (resp.status == 100) {
console.log("100")
showconsolealert(resp.message, 1);
scrolltextarea();
console.log('console error');
return false;
}
......@@ -160,8 +157,6 @@ function disableassociated(shockindex) {
$('#runstochastic').click(async function () {
//getting all the necessary info from the forms
// var taylororder = $('#taylororder').val();
// var irfperiods = $('#irfperiods').val();
var ssstatus = $('#stomodelsteadystatestatus').val();
var endonum = $('#stomodel_endonum').val();
var exonum = $('#stomodel_exonum').val();
......@@ -173,56 +168,12 @@ $('#runstochastic').click(async function () {
var shockindex;
var attributeflag = [];
var shockspairs = [];
// var shocksflag = [];
var sstype = 0;
for (i = 0; i < exonum; i++) {
attributeflag[i] = 0;
}
// setup tab checks
// // taylor order check
// if (taylororder == null || taylororder == "") {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'You did not specify the Taylor approximation order.');
// return (0);
// } else {
// if (!(Number.isInteger(Number(taylororder)))) {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'The Taylor approximation order is not an integer number.');
// return (0);
// }
// if (Number(taylororder) < 1) {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'The Taylor approximation order can not be lower than 1. Admissible values are 1, 2 and 3.');
// return (0);
// }
// if (Number(taylororder) > 2) {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'The webapp only allows Taylor approximation up to order 2 for now. Admissible values are 1 and 2.');
// return (0);
// }
// }
// // irf periods order check
// if (irfperiods == null || irfperiods == "") {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'You did not specify a number of periods for the IRFs.');
// return (0);
// } else {
// if (!(Number.isInteger(Number(irfperiods)))) {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'The number of periods for the IRFs is not an integer number.');
// return (0);
// }
// if (Number(irfperiods) < 0) {
// $('.nav-tabs a[href="#stosimsetuptable"]').tab('show');
// popthis('Setup error.', 'The number of periods for the IRFs can not be negative.');
// return (0);
// }
// }
// steady-state info check
if (ssstatus == 99) {
sstext = $('#stoSSblock').val();
......@@ -389,9 +340,6 @@ $('#runstochastic').click(async function () {
for (let element of stooptionslist) {
if ($("#stoopt_id_" + stooptcounter.toString()).is(':checked')) {
console.log("#stoopt_id_" + stooptcounter.toString() + " is checked");
if (element.stooptinputtype == 0) { //checking no input options
stooptionsdescription.push({
'stooptindex': parseInt(stooptcounter, 10),
......@@ -399,7 +347,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': parseInt(element.stooptinputtype, 10),
'stooptvalue': ''
});
console.log(stooptionsdescription);
}
if (element.stooptinputtype == 1) { //checking integer input options
......@@ -431,8 +378,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': parseInt(element.stooptinputtype, 10),
'stooptvalue': parseInt(stooptval, 10)
});
console.log(stooptionsdescription);
}
......@@ -460,8 +405,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': parseInt(element.stooptinputtype, 10),
'stooptvalue': parseFloat(stooptval, 10)
});
console.log(stooptionsdescription);
}
......@@ -496,8 +439,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 1,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else { //if not a number we verify if it is a range or an array of numbers
......@@ -506,9 +447,7 @@ $('#runstochastic').click(async function () {
if (stooptval.indexOf(':') > -1) { //it is a range
var stooptsplit = stooptval.split(':');
var stooptsplitlength = stooptsplit.length;
// console.log('stooptsplit')
// console.log(stooptsplit[0])
// console.log(stooptsplit[1])
if (stooptsplitlength == 2) { //the range should divide into two numbers
......@@ -541,7 +480,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 10,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else {
$('.nav-tabs a[href="#stooptions"]').tab('show');
popthis('Options error.', stooptdyn + ' value is not properly entered.');
......@@ -571,7 +509,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 11,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
}
} else {
$('.nav-tabs a[href="#stooptions"]').tab('show');
......@@ -622,7 +559,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 2,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else { //if not a number we verify if it is a range or an array of numbers
......@@ -648,7 +584,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 21,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else {
$('.nav-tabs a[href="#stooptions"]').tab('show');
......@@ -666,9 +601,6 @@ $('#runstochastic').click(async function () {
stooptval = $("#stoopt_input_" + stooptcounter.toString() + " option:selected").text();
stooptdyn = (element.stooptdynarename).bold();
console.log(stooptindex);
console.log(stooptval);
if (stooptindex == null) {
$('.nav-tabs a[href="#stooptions"]').tab('show');
popthis('Options error.', 'You have activated the ' + stooptdyn + ' option without selection a value. Please deactivate this option if you are not using it or want to use its default value.');
......@@ -681,8 +613,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 5,
'stooptvalue': stooptval
});
console.log(stooptionsdescription);
}
}
......@@ -693,11 +623,6 @@ $('#runstochastic').click(async function () {
stooptval = stooptval.trim();
stooptdyn = (element.stooptdynarename).bold();
console.log('Inside 60')
console.log(stooptval);
console.log(stooptcounter);
if ((stooptval == null || stooptval == "")) { //entry is empty
$('.nav-tabs a[href="#stooptions"]').tab('show');
popthis('Options error.', 'You have activated the ' + stooptdyn + ' option without specifying a value. Please deactivate this option if you are not using it or want to use its default value.');
......@@ -736,8 +661,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 11,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else {
//we check for a single endogenous entry
var endocheckflag = 0;
......@@ -762,7 +685,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 60,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
}
// }
......@@ -771,8 +693,6 @@ $('#runstochastic').click(async function () {
}
if (stooptcounter == 8) { //irf_shocks option
console.log('Inside 60+8');
console.log(stooptval.indexOf(' '));
if (stooptval.indexOf(' ') > -1) { //it is an array
var stooptsplit = stooptval.split(' ');
var stooptsplitlength = stooptsplit.length;
......@@ -800,7 +720,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 60,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
} else { //is not an array--> could be a single var
var exocheckflag = 0;
......@@ -824,7 +743,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 60,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
}
......@@ -855,7 +773,6 @@ $('#runstochastic').click(async function () {
'stooptinputtype': 60,
'stooptvalue': dynlist
});
console.log(stooptionsdescription);
}
......@@ -889,8 +806,6 @@ $('#runstochastic').click(async function () {
document.getElementById('inner').appendChild(div);
// console.log(stosimvaldata)
$.ajax({
url: $(editorform).attr('action'),
headers: {
......@@ -903,20 +818,13 @@ $('#runstochastic').click(async function () {
success: function (resp) {
// console.log(resp)
if (resp.status == 200) {
console.log("200")
return popthis('Error', resp.message);
} else if (resp.status == 100) {
console.log("100")
showconsolealert(resp.message, 1);
scrolltextarea();
console.log('console error');
return false;
}
console.log('All done here !')
},
error: function () {
console.log('there was a problem checking the fields');
......@@ -938,10 +846,6 @@ $('#runstochastic').click(async function () {
$(function () {
socket.on('stochasticsimfinish', function (msg) {
// $('#messages').append($('<li>').text(msg));
// console.log(msg);
scrolltextarea();
......@@ -978,7 +882,6 @@ $(function () {
y = 0;
for (x in stomatlabdata.var_list) {
specvarname = stomatlabdata.var_list[y].trim();
console.log(specvarname.key)
plotdropdown += '<li onclick="stoplotspectral(' + y + ')"><a href="#stophere">' + specvarname + '</a></li>';
y = y + 1;
}
......
......@@ -121,6 +121,11 @@
<textarea id="preprocessorout" class="form-control"
style="min-width: 100%; resize:none; background-color:transparent;" rows="30" readonly>
</textarea>
<br>
<button id="consoleclearbtn" type="button" class="btn btn-default" aria-label="Left Align">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</button>
</div>
<div id="output" class="tab-pane fade in">
......@@ -234,6 +239,8 @@
</div>
</div>
<!-- perfect foresight modal Start -->
<div class="modal fade" id="perforModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
......@@ -254,36 +261,14 @@
<div class="modal-body">
<ul class="nav nav-tabs tabs-up" id="performodaltabs">
<li class="active"><a data-toggle="tab" href="#perforsetuptable">Setup</a></li>
<li><a data-toggle="tab" href="#perforseqexp">Shocks</a></li>
<li class="active"><a data-toggle="tab" href="#perforseqexp">Shocks</a></li>
<li><a data-toggle="tab" href="#perforsetuptable">Setup</a></li>
<li><a data-toggle="tab" href="#perfoptions">Options</a></li>
</ul>
<br>
<div class="tab-content">
<div id="perforsetuptable" class="tab-pane fade in active">
<h4>Additional setup</h4>
<table class="table table-striped small">
<thead>
<tr>
<th>#</th>
<th>Option</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Number of simulation periods</td>
<td><input class="form-control no-border input-sm" name="simperiods" id="simperiods"
placeholder="200" type="text" value="200"></td>
<input id="model_endonum" name="model_endonum" value="" type="hidden">
<input id="model_exonum" name="model_exonum" value="" type="hidden">
</tr>
</tbody>
</table>
<div id="perforssinittable"></div>
</div>
<div id="perforseqexp" class="tab-pane fade in">
<div id="perforseqexp" class="tab-pane fade in active">
<h4>Shocks</h4>
<button id="addshock" type="button" title="addshock" class="btn btn-success btn-sm">Add shock</button>
<table id="perforseqexptable" class="table table-striped small">
......@@ -305,6 +290,33 @@
</table>
</div>
<div id="perforsetuptable" class="tab-pane fade in">
<h4>Additional setup</h4>
<input id="model_endonum" name="model_endonum" value="" type="hidden">
<input id="model_exonum" name="model_exonum" value="" type="hidden">
<div id="perforssinittable"></div>
</div>
<div id="perfoptions" class="tab-pane fade in">
<h4>Options</h4>
<table id="perfoptiontable" class="table table-striped small">
<thead>
<tr>