Commit c4a213d1 authored by LIGNEUL CLEMENT's avatar LIGNEUL CLEMENT
Browse files

activate all buttons + improve display and code

parent 575d4313
......@@ -271,14 +271,17 @@ export class Compile {
fileDialog.setNameFilter('EASEA files (*.ez)');
if(fileDialog.exec()){
this.ez_file_address = fileDialog.selectedFiles().toString();
this.dir_path = util.get_path(this.ez_file_address);
run_obj.setDirPath(this.dir_path);
var file = fileDialog.selectedFiles().toString();
if(file){
this.ez_file_address = file;
this.dir_path = util.get_path(this.ez_file_address);
run_obj.setDirPath(this.dir_path);
file_loaded.setText(util.get_file_name(this.ez_file_address));
run_obj.setEzFileAddress(this.ez_file_address);
}
}
console.log(this.ez_file_address);
file_loaded.setText(util.get_file_name(this.ez_file_address));
run_obj.setEzFileAddress(this.ez_file_address);
});
// load file box
......@@ -309,6 +312,4 @@ export class Compile {
setReady(val: Number){
this.ready = val;
}
}
\ No newline at end of file
import { Direction, QBoxLayout, QDialog, QCheckBox, QPushButton, QWidget, QLabel, QFileDialog } from "@nodegui/nodegui";
import { Direction, QBoxLayout, QDialog, QCheckBox, QPushButton, QWidget, QLabel, QFileDialog, WindowType } from "@nodegui/nodegui";
import { Advanced_option_widget } from "./advanced_option_widget";
import { general_css } from "./style";
import * as util from './utilities';
export class Island_options_win{
......@@ -12,6 +13,7 @@ export class Island_options_win{
constructor(){
this.window = new QDialog();
this.window.setWindowTitle('Islands Options');
this.window.setWindowFlag(WindowType.FramelessWindowHint, true);
this.reeavaluate = false;
this.server_port = NaN;
this.migration_proba = NaN;
......@@ -21,6 +23,9 @@ export class Island_options_win{
const reevaluate_im = new QCheckBox();
reevaluate_im.setText('Evaluate Immigrants');
reevaluate_im.addEventListener('stateChanged', ()=>{
this.reeavaluate = reevaluate_im.isChecked();
});
// à mettre dans remote island
const ip_widget = new QWidget();
......@@ -36,17 +41,44 @@ export class Island_options_win{
fileDialog.setFileMode(0); // load an existing file
if(fileDialog.exec()){
this.ip_file = fileDialog.selectedFiles().toString();
var file = fileDialog.selectedFiles().toString();
if(file){
this.ip_file = file
file_loaded.setText('IP file : ' + util.get_file_name(this.ip_file));
}
}
file_loaded.setText('IP file : ' + util.get_file_name(this.ip_file));
});
ip_layout.addWidget(file_loaded);
ip_layout.addWidget(ip_file_btn);
const proba_migration = new Advanced_option_widget('Migration Proba :', 0);
const proba_migration = new Advanced_option_widget('Migration Probability :', 0);
proba_migration.text_edit.addEventListener('textChanged', ()=>{
var text = proba_migration.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.migration_proba = NaN;
return ;
}
if(!isNaN(val))
this.migration_proba = val;
});
const server_port = new Advanced_option_widget('Server Port :', 0);
server_port.text_edit.addEventListener('textChanged', ()=>{
var text = server_port.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.server_port = NaN;
return ;
}
if(!isNaN(val))
this.server_port = val;
});
// close and save buttons
const btn_layout = new QBoxLayout(Direction.LeftToRight);
......@@ -56,23 +88,36 @@ export class Island_options_win{
const save_btn = new QPushButton();
save_btn.setText('Save');
save_btn.addEventListener('clicked', ()=>{
this.window.close();
var errors = [];
var ok = 1;
if(isNaN(Number(proba_migration.text_edit.toPlainText()))){
ok = 0;
errors.push('Migration Probability');
}
if(isNaN(Number(server_port.text_edit.toPlainText()))){
ok = 0;
errors.push('Server Port');
}
if(ok){
this.window.close();
} else {
util.print_errors(errors);
}
});
save_btn.setFixedSize(100, 25);
const reset_btn = new QPushButton();
reset_btn.setText('Reset');
reset_btn.addEventListener('clicked', ()=>{
this.ip_file = '';
file_loaded.setText('IP file :');
this.migration_proba = NaN;
proba_migration.text_edit.setText('');
this.reeavaluate = false;
reevaluate_im.setChecked(false);
this.server_port = NaN;
server_port.text_edit.setText('');
});
reset_btn.setFixedSize(100, 25);
......@@ -80,15 +125,16 @@ export class Island_options_win{
btn_layout.addWidget(save_btn);
btn_layout.addWidget(reset_btn);
main_layout.addWidget(reevaluate_im);
main_layout.addWidget(proba_migration.widget);
main_layout.addWidget(ip_widget);
main_layout.addWidget(server_port.widget);
main_layout.addWidget(reevaluate_im);
main_layout.addWidget(btn_widget);
this.window.setLayout(main_layout);
this.window.adjustSize();
this.window.setFixedSize(this.window.size().width(), this.window.size().height());
this.window.setStyleSheet(general_css);
}
execution(){
......
import { Direction, QBoxLayout, QDialog, QPushButton, QWidget } from "@nodegui/nodegui";
import { Direction, QBoxLayout, QDialog, QPushButton, QWidget, WindowType } from "@nodegui/nodegui";
import { Advanced_option_widget } from "./advanced_option_widget";
import { print_errors } from "./utilities";
export class Offspring_options_win{
window: QDialog
......@@ -11,6 +12,7 @@ export class Offspring_options_win{
constructor(){
this.window = new QDialog();
this.window.setWindowTitle('Offspring Options');
this.window.setWindowFlag(WindowType.FramelessWindowHint, true);
this.surviving_off = NaN;
this.reduce_op = 'Tournament';
this.reduce_pressure = 2.0;
......@@ -19,12 +21,57 @@ export class Offspring_options_win{
const main_layout = new QBoxLayout(Direction.TopToBottom);
const nb_off = new Advanced_option_widget('Offspring Size :', 0);
nb_off.text_edit.addEventListener('textChanged', ()=>{
var text = nb_off.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.size_off = NaN;
return ;
}
if(!isNaN(val))
this.size_off = val;
});
const surviving_offspring = new Advanced_option_widget('Surviving Offspring :', 0);
surviving_offspring.text_edit.addEventListener('textChanged', ()=>{
var text = surviving_offspring.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.surviving_off = NaN;
return ;
}
if(!isNaN(val))
this.surviving_off = val;
});
const reduce_off_op = new Advanced_option_widget('Reduce Operator :', 0, 'Tournament');
reduce_off_op.text_edit.addEventListener('textChanged', ()=>{
var text = reduce_off_op.text_edit.toPlainText();
if(text === ''){
this.reduce_op = 'Tournament';
} else {
this.reduce_op = text;
}
});
const reduce_off_pressure = new Advanced_option_widget('Reduce Pressure :', 0, '2.0');
reduce_off_pressure.text_edit.addEventListener('textChanged', ()=>{
var text = reduce_off_pressure.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.reduce_pressure = NaN;
return ;
}
if(!isNaN(val))
this.reduce_pressure = val;
});
// close and save buttons
const btn_layout = new QBoxLayout(Direction.LeftToRight);
......@@ -34,23 +81,41 @@ export class Offspring_options_win{
const save_btn = new QPushButton();
save_btn.setText('Save');
save_btn.addEventListener('clicked', ()=>{
this.window.close();
var errors = [];
var ok = 1;
if(isNaN(Number(reduce_off_pressure.text_edit.toPlainText()))){
ok = 0;
errors.push('Reduce Pressure');
}
if(isNaN(Number(surviving_offspring.text_edit.toPlainText()))){
ok = 0;
errors.push('Surviving Offspring');
}
if(isNaN(Number(nb_off.text_edit.toPlainText()))){
ok = 0;
errors.push('Offspring Size');
}
if(ok){
this.window.close();
} else {
print_errors(errors);
}
});
save_btn.setFixedSize(100, 25);
const reset_btn = new QPushButton();
reset_btn.setText('Reset');
reset_btn.addEventListener('clicked', ()=>{
this.reduce_op = 'Trounament';
reduce_off_op.text_edit.setText('');
this.reduce_pressure = 2.0;
reduce_off_pressure.text_edit.setText('');
this.size_off = NaN;
nb_off.text_edit.setText('');
this.surviving_off = NaN;
surviving_offspring.text_edit.setText('');
});
reset_btn.setFixedSize(100, 25);
......
import { Direction, QBoxLayout, QDialog, QPushButton, QWidget } from "@nodegui/nodegui";
import { Direction, QBoxLayout, QDialog, QPushButton, QWidget, WindowType } from "@nodegui/nodegui";
import { Advanced_option_widget } from "./advanced_option_widget";
import * as util from './utilities';
export class Parent_options_win{
surviving: number;
......@@ -11,6 +12,7 @@ export class Parent_options_win{
constructor(){
this.window = new QDialog();
this.window.setWindowTitle('Parents Options');
this.window.setWindowFlag(WindowType.FramelessWindowHint, true);
this.surviving = NaN;
this.reduce_op = 'Tournament';
this.reduce_pressure = 2.0;
......@@ -19,12 +21,57 @@ export class Parent_options_win{
const main_layout = new QBoxLayout(Direction.TopToBottom);
const elite = new Advanced_option_widget('Elite Parents :', 0, '0');
elite.text_edit.addEventListener('textChanged', ()=>{
var text = elite.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.nb_elite = NaN;
return ;
}
if(!isNaN(val))
this.nb_elite = val;
});
const surviving_parent = new Advanced_option_widget('Surviving Parents :', 0)
surviving_parent.text_edit.addEventListener('textChanged', ()=>{
var text = surviving_parent.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.surviving = NaN;
return ;
}
if(!isNaN(val))
this.surviving = val;
});
const reduce_parent_op = new Advanced_option_widget('Reduction Operator :', 0, 'Tournament');
reduce_parent_op.text_edit.addEventListener('textChanged', ()=>{
var text = reduce_parent_op.text_edit.toPlainText();
if(text === ''){
this.reduce_op = 'Tournament';
} else {
this.reduce_op = text;
}
});
const reduce_parent_pressure = new Advanced_option_widget('Reduce pressure :', 0, '2.0');
reduce_parent_pressure.text_edit.addEventListener('textChanged', ()=>{
var text = reduce_parent_pressure.text_edit.toPlainText();
var val = Number(text);
if(text === ''){
this.reduce_pressure = NaN;
return ;
}
if(!isNaN(val))
this.reduce_pressure = val;
});
// close and save buttons
const btn_layout = new QBoxLayout(Direction.LeftToRight);
......@@ -34,23 +81,41 @@ export class Parent_options_win{
const save_btn = new QPushButton();
save_btn.setText('Save');
save_btn.addEventListener('clicked', ()=>{
this.window.close();
var errors = [];
var ok = 1;
if(isNaN(Number(surviving_parent.text_edit.toPlainText()))){
ok = 0;
errors.push('Surviving Parents');
}
if(isNaN(Number(reduce_parent_pressure.text_edit.toPlainText()))){
ok = 0;
errors.push('Reduce Pressure');
}
if(isNaN(Number(elite.text_edit.toPlainText()))){
ok = 0;
errors.push('Elite Parents');
}
if(ok){
this.window.close();
} else {
util.print_errors(errors);
}
});
save_btn.setFixedSize(100, 25);
const reset_btn = new QPushButton();
reset_btn.setText('Reset');
reset_btn.addEventListener('clicked', ()=>{
this.surviving = NaN;
surviving_parent.text_edit.setText('');
this.reduce_pressure = 2.0;
reduce_parent_pressure.text_edit.setText('');
this.reduce_op = 'Tournament';
reduce_parent_op.text_edit.setText('');
this.nb_elite = NaN;
elite.text_edit.setText('');
});
reset_btn.setFixedSize(100, 25);
......
......@@ -168,7 +168,7 @@ export class Pseudo_term{
}
}
run(cmd: string, params?: string, dir?: string){
run(cmd: string, params?: string, dir?: string, rank?: number){
var array_params: string[] = [];
if(params == undefined){
this.text.insertPlainText('\n$ ' + cmd + '\n');
......@@ -196,7 +196,11 @@ export class Pseudo_term{
child.on('error', function(err) {
var type = err.toString().split(" ");
if(type[type.length-1] === "ENOENT"){
new Win_alert(err + '\nExecution impossible');
if(rank !== undefined){
new Win_alert(err + '\nExecution impossible try to recompile', 'Process ' + rank);
} else {
new Win_alert(err + '\nExecution impossible try to recompile');
}
} else {
new Win_alert(err + '');
}
......
This diff is collapsed.
import { Pseudo_term } from './pseudo_term';
import {Win_alert } from './win_alert';
import * as util from './utilities';
import { running_proc } from './index';
import { running_proc, run_obj } from './index';
import { QGridLayout, QLabel, QWidget, QBoxLayout, QPushButton, QCheckBox } from '@nodegui/nodegui';
import { Run_options } from './run_options_win';
import { Parent_options_win } from './parents_options_win';
......@@ -15,7 +15,11 @@ export class Run_tab {
ready: Number; // ready to start ? (0 no 1 yes)
batch_display: QLabel;
options: string;
option_obj: Run_options;
option_obj = new Run_options();
island_obj = new Island_options_win();
parent_obj = new Parent_options_win();
off_obj = new Offspring_options_win();
island_model = false;
constructor(ez_file: string, dir: string){
......@@ -25,7 +29,6 @@ export class Run_tab {
this.ready = 0;
this.batch_display = new QLabel();
this.options = '';
this.option_obj = new Run_options();
}
generate(){
......@@ -41,20 +44,20 @@ export class Run_tab {
// activate island model
const activate_island_model = new QCheckBox();
activate_island_model.setText('Activate Island Model');
activate_island_model.addEventListener('stateChanged', ()=>{
this.island_model = activate_island_model.isChecked();
});
// option run
// general options
const run_option = new Run_options();
const general_option_btn = new QPushButton();
general_option_btn.setText("General options");
general_option_btn.setFixedSize(150, 30);
general_option_btn.addEventListener('clicked', () => {
var runned = run_option.execution();
this.option_obj = run_option.execution();
this.options = ''.concat(runned.run_options);
this.option_obj = runned;
if(runned.batch_size <= 30 && runned.batch_size > 0){
this.batch_size = runned.batch_size;
if(this.option_obj.batch_size <= 30 && this.option_obj.batch_size > 0){
this.batch_size = this.option_obj.batch_size;
this.batch_display.setText("Batch size : " + this.batch_size.toString());
}
});
......@@ -65,7 +68,7 @@ export class Run_tab {
parent_btn.setText("Parents options");
parent_btn.setFixedSize(150, 30);
parent_btn.addEventListener('clicked', () => {
var runned = parent_options.execution();
this.parent_obj = parent_options.execution();
});
// offspring options
......@@ -74,7 +77,7 @@ export class Run_tab {
offsp_btn.setText("Offspring options");
offsp_btn.setFixedSize(150, 30);
offsp_btn.addEventListener('clicked', () => {
var runned = offsp_option.execution();
this.off_obj = offsp_option.execution();
});
// remote Island options
......@@ -83,7 +86,7 @@ export class Run_tab {
island_btn.setText("Island model options");
island_btn.setFixedSize(150, 30);
island_btn.addEventListener('clicked', () => {
var runned = island_option.execution();
this.island_obj = island_option.execution();
});
......@@ -97,9 +100,11 @@ export class Run_tab {
return;
}
var options = '';
run_btn.setEnabled(false);
parent_btn.setEnabled(false);
island_btn.setEnabled(false);
offsp_btn.setEnabled(false);
general_option_btn.setEnabled(false);
if(this.ez_file_address){
var cmd = this.ez_file_address.substring(0, this.ez_file_address.length-3);
......@@ -108,25 +113,167 @@ export class Run_tab {
if(this.batch_size > 0 && this.batch_size <= 30){
for(var i = 0; i < Number(this.batch_size); i++){
this.options = '';
if(i !== 0 || !this.option_obj.plot_stats){
this.options = this.options.concat(' --plotStats 0')
} else {
this.options = this.options.concat(' --plotStats 1')
}
if(!isNaN(this.option_obj.compression))
this.options = this.options.concat(' --compression ' + this.option_obj.compression);
if(!isNaN(this.option_obj.pop_size))
this.options = this.options.concat(' --popSize ' + this.option_obj.pop_size);
if(!isNaN(this.option_obj.elite_type))
this.options = this.options.concat(' --eliteType ' + this.option_obj.elite_type);
if(!isNaN(this.option_obj.nb_gen))
this.options = this.options.concat(' --nbGen ' + this.option_obj.nb_gen);
if(!isNaN(this.option_obj.time_limit))
this.options = this.options.concat(' --timeLimit ' + this.option_obj.time_limit);
if(this.option_obj.select_op && this.option_obj.select_op.toLowerCase() !== 'tournament')
this.options = this.options.concat(' --selectionOperator ' + this.option_obj.select_op);
if(!isNaN(this.option_obj.select_pressure))
this.options = this.options.concat(' --selectionPressure ' + this.option_obj.select_pressure);
if(this.option_obj.reduce_final_op && this.option_obj.reduce_final_op.toLowerCase() !== 'tournament')
this.options = this.options.concat(' --reduceFinalOperator ' + this.option_obj.reduce_final_op);
if(!isNaN(this.option_obj.reduce_final_pressure))
this.options = this.options.concat(' --reduceFinalPressure ' + this.option_obj.reduce_final_pressure);
if(!isNaN(this.option_obj.optimize_it))
this.options = this.options.concat(' --optimiseIterations ' + this.option_obj.optimize_it);
if(!isNaN(this.option_obj.baldwinism))
this.options = this.options.concat(' --baldwinism ' + this.option_obj.baldwinism);
if(this.option_obj.output_file)
this.options = this.options.concat(' --outputfile ' + this.option_obj.output_file);
if(this.option_obj.input_file)
this.options = this.options.concat(' --inputfile ' + this.option_obj.input_file);
if(this.option_obj.generate_csv_file)
this.options = this.options.concat(' --generateCSVFile 1');
if(this.option_obj.generate_plot_script)
this.options = this.options.concat(' --generatePlotScript 1');
if(this.option_obj.generate_r_script)
this.options = this.options.concat(' --generateRScript 1');
if(this.option_obj.print_init_pop)
this.options = this.options.concat(' --printInitialPopulation 1');
if(this.option_obj.print_final_pop)
this.options = this.options.concat(' --printFinalPopulation 1');
if(this.option_obj.save_pop)
this.options = this.options.concat(' --savePopulation 1');
if(this.option_obj.start_file)
this.options = this.options.concat(' --startFromFile 1');
if(!isNaN(this.option_obj.fstgpu_param))
this.options = this.options.concat(' --fstgpu ' + this.option_obj.fstgpu_param);
if(!isNaN(this.option_obj.lstgpu_param))
this.options = this.options.concat(' --lstgpu ' + this.option_obj.lstgpu_param);
if(this.option_obj.u1)
this.options = this.options.concat(' --u1 ' + this.option_obj.u1);