📄 gaaparams.java
字号:
string2Label.add(new Label(" Secondary Strategy String:"));
string2Text.add(txtString2);
string4.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel string4Left = new Panel();
Panel string4Label = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel string4Text = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel string4Right = new Panel();
string4.add("1",string4Left);
string4.add("4",string4Label);
string4.add("8",string4Text);
string4.add("1",string4Right);
string4Label.add(new Label(" Secondary Strategy Percent:"));
string4Text.add(txtString4);
choice3.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel choice3Left = new Panel();
Panel choice3Label = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel choice3Text = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel choice3Right = new Panel();
choice3.add("1",choice3Left);
choice3.add("4",choice3Label);
choice3.add("8",choice3Text);
choice3.add("1",choice3Right);
choice3Label.add(new Label("Select Test String:"));
choice3Text.add(chcChoice3);
Panel bottom = new Panel();
String butTitles[] = {"Update","Help"};
strategyButtons = createButtonArray(butTitles, bottom);
Label title = new Label("Experimenting with Evolution of Strategies (IPD Oriented)", Label.CENTER);
title.setFont(f);
strategyPanel.add("North",title);
strategyPanel.add("Center",data);
strategyPanel.add("South",bottom);
}
private void makeUdfPanel() {
int i, num = 10;
Font f = new Font("Helvetica",Font.BOLD,14);
udfPanel.setLayout(new BorderLayout());
udfPanel.setFont(f);
Panel data = new Panel();
data.setLayout(new SplitterLayout(SplitterLayout.VERTICAL));
txtExpression = new TextArea("",5,50,TextArea.SCROLLBARS_HORIZONTAL_ONLY);
//txtExpression = new TextArea("",5,50,TextArea.SCROLLBARS_NONE);
txtMin = new TextField(10);
txtMax = new TextField(10);
txtNumGenes = new TextField(10);
txtNumVariables = new TextField(10);
txtExitValue = new TextField(10);
txtExpression.addMouseListener( this );
txtMin.addMouseListener( this );
txtMax.addMouseListener( this );
txtNumGenes.addMouseListener( this );
txtNumVariables.addMouseListener( this );
txtExitValue.addMouseListener( this );
CheckboxGroup group = new CheckboxGroup();
chkMin = new Checkbox("Minimize");
chkMin.setCheckboxGroup(group);
chkMax = new Checkbox("Maximize");
chkMax.setCheckboxGroup(group);
Panel minmaxGroup = new Panel();
minmaxGroup.add(chkMin);
minmaxGroup.add(chkMax);
Panel expression = new Panel();
Panel numgenes = new Panel();
Panel numvars = new Panel();
Panel min = new Panel();
Panel max = new Panel();
Panel minmax = new Panel();
Panel exval = new Panel();
Panel topDummy = new Panel();
Panel botDummy = new Panel();
data.add("1",topDummy);
data.add("8",expression);
data.add("2",numgenes);
data.add("2",numvars);
data.add("2",min);
data.add("2",max);
data.add("2",exval);
data.add("2",minmax);
data.add("1",botDummy);
expression.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel expLeft = new Panel();
Panel expLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel expText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel expRight = new Panel();
expression.add("1",expLeft);
expression.add("4",expLabel);
expression.add("8",expText);
expression.add("1",expRight);
expLabel.add(new Label("Expression:"));
expText.add(txtExpression);
numgenes.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel numgenesLeft = new Panel();
Panel numgenesLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel numgenesText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel numgenesRight = new Panel();
numgenes.add("1",numgenesLeft);
numgenes.add("4",numgenesLabel);
numgenes.add("8",numgenesText);
numgenes.add("1",numgenesRight);
numgenesLabel.add(new Label("Number of genes:"));
numgenesText.add(txtNumGenes);
numvars.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel numvarsLeft = new Panel();
Panel numvarsLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel numvarsText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel numvarsRight = new Panel();
numvars.add("1",numvarsLeft);
numvars.add("4",numvarsLabel);
numvars.add("8",numvarsText);
numvars.add("1",numvarsRight);
numvarsLabel.add(new Label("Number of variables:"));
numvarsText.add(txtNumVariables);
min.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel minLeft = new Panel();
Panel minLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel minText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel minRight = new Panel();
min.add("1",minLeft);
min.add("4",minLabel);
min.add("8",minText);
min.add("1",minRight);
minLabel.add(new Label("Common minimum value:"));
minText.add(txtMin);
max.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel maxLeft = new Panel();
Panel maxLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel maxText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel maxRight = new Panel();
max.add("1",maxLeft);
max.add("4",maxLabel);
max.add("8",maxText);
max.add("1",maxRight);
maxLabel.add(new Label("Common maximum value:"));
maxText.add(txtMax);
exval.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel exvalLeft = new Panel();
Panel exvalLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel exvalText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel exvalRight = new Panel();
exval.add("1",exvalLeft);
exval.add("4",exvalLabel);
exval.add("8",exvalText);
exval.add("1",exvalRight);
exvalLabel.add(new Label("Exit value:"));
exvalText.add(txtExitValue);
minmax.setLayout(new SplitterLayout(SplitterLayout.HORIZONTAL));
Panel minmaxLeft = new Panel();
Panel minmaxLabel = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel minmaxText = new Panel(new FlowLayout(FlowLayout.LEFT));
Panel minmaxRight = new Panel();
minmax.add("1",minmaxLeft);
minmax.add("4",minmaxLabel);
minmax.add("8",minmaxText);
minmax.add("1",minmaxRight);
minmaxLabel.add(new Label("Optimization mode:"));
minmaxText.add(minmaxGroup);
Panel bottom = new Panel();
String butTitles[] = {"Update","Help"};
udfButtons = createButtonArray(butTitles, bottom);
Label title = new Label("Define expression to optimize", Label.CENTER);
title.setFont(f);
udfPanel.add("North",title);
udfPanel.add("Center",data);
udfPanel.add("South",bottom);
}
private void initUdfPanel() {
txtExpression.setText(" "+problem.udfExpression);
txtNumGenes.setText(" "+problem.genesNumber);
txtNumVariables.setText(" "+problem.variablesNumber);
txtMin.setText(" "+dFormat.format(problem.minVal));
txtMax.setText(" "+dFormat.format(problem.maxVal));
txtExitValue.setText(" "+dFormat.format(problem.exitValue));
if (problem.minmaxType == 1) {
chkMax.setState(true);
}
else {
chkMin.setState(true);
}
}
private void updateStrategyPanel() {
try {
problem.inputString1 = txtString1.getText().trim();
problem.inputString2 = txtString2.getText().trim();
problem.udfInteger = Integer.parseInt(txtString4.getText().trim());
problem.udfDouble = Double.valueOf(txtString3.getText().trim()).doubleValue();
problem.udfString = txtString5.getText().trim();
}
catch (Exception e) {
int ret = MsgDialog.msg("Error", "Update failed", MsgDialog.MB_OK, 0);
return;
}
problem.updateDataFields();
GaaApplet.statusLabel.setText("Please wait...");
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
pop.updateParams();
/*
problem.defineAlleles();
pop.initPopulation();
updateDefGrid();
updateMapGrid();
*/
GaaApplet.statusLabel.setText("");
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
int ret = MsgDialog.msg("Ok", "Function Updated", MsgDialog.MB_OK, 0);
}
private void updateUdfPanel() {
try {
int gn = Integer.parseInt(txtNumGenes.getText().trim());
int vn = Integer.parseInt(txtNumVariables.getText().trim());
if (gn%vn != 0) {
int ret = MsgDialog.msg("Wrong values", "Genes number must be a whole number multiplication of variables number", MsgDialog.MB_OK, 0);
return;
}
}
catch (Exception e) {
int ret = MsgDialog.msg("Error", "Illegitimate values", MsgDialog.MB_OK, 0);
return;
}
try {
problem.problemCode = 3;
problem.defOrder = 0;
problem.mapOrder = 0;
problem.gaType = 1;
problem.udfExpression = txtExpression.getText().trim();
problem.udfExpression = problem.udfExpression.replace('\n',' ');
problem.genesNumber = Integer.parseInt(txtNumGenes.getText().trim());
problem.variablesNumber = Integer.parseInt(txtNumVariables.getText().trim());
problem.minVal = Double.valueOf(txtMin.getText().trim()).doubleValue();
problem.maxVal = Double.valueOf(txtMax.getText().trim()).doubleValue();
problem.exitValue = Double.valueOf(txtExitValue.getText().trim()).doubleValue();
if (chkMax.getState()) {
problem.minmaxType = 1;
}
else {
problem.minmaxType = 2;
}
}
catch (Exception e) {
int ret = MsgDialog.msg("Error", "Update failed", MsgDialog.MB_OK, 0);
return;
}
problem.updateDataFields();
GaaApplet.statusLabel.setText("Please wait...");
this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
pop.updateParams();
problem.defineAlleles();
pop.initPopulation();
updateDefGrid();
updateMapGrid();
GaaApplet.statusLabel.setText("");
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
int ret = MsgDialog.msg("Ok", "Function Updated", MsgDialog.MB_OK, 0);
}
private void initDefGrid() {
if (textDefNumAlleles.getText().equals("")) {
int ret = MsgDialog.msg("Missing Data", "Number of alleles not defined", MsgDialog.MB_OK, 0);
}
else {
int newNum = Integer.parseInt(textDefNumAlleles.getText());
int oldNum = defGrid.getTotalRows();
int i;
defGrid.setRepaint(false);
for (i=0;i<oldNum;i++) {
defGrid.deleteGridRow(0);
}
for (i=0;i<newNum;i++) {
defGrid.setGridCell(i,0,Integer.toString(i));
defGrid.setGridCell(i,1,"0");
defGrid.setGridCell(i,2,"0");
defGrid.setGridCell(i,3,"0");
defGrid.setGridCell(i,4,"0");
defGrid.setGridCell(i,5,"0");
defGrid.setGridCell(i,6,"Allele No."+i);
}
defGrid.setRepaint(true);
}
}
private void initMapGrid() {
int oldNum = mapGrid.getTotalRows();
int i;
mapGrid.setRepaint(false);
for (i=0;i<oldNum;i++) {
mapGrid.deleteGridRow(0);
}
for (i=0;i<oldNum;i++) {
mapGrid.setGridCell(i,0,Integer.toString(i));
mapGrid.setGridCell(i,1,"0");
mapGrid.setGridCell(i,2,"0");
mapGrid.setGridCell(i,3,"0");
mapGrid.setGridCell(i,4,"0");
mapGrid.setGridCell(i,5,"0");
mapGrid.setGridCell(i,6,"0");
mapGrid.setGridCell(i,7,"0");
mapGrid.setGridCell(i,8,"0");
mapGrid.setGridCell(i,9,"0");
mapGrid.setGridCell(i,10,"0");
}
mapGrid.setRepaint(true);
}
private void copyDefGridSelected() {
int num = defGrid.getTotalRows();
int row = defGrid.getSelectedRow();
int i;
defGrid.setRepaint(false);
for (i=0;i<num;i++) {
//defGrid.setGridCell(i,0,Integer.toString(i));
defGrid.setGridCell(i,1,defGrid.getGridCell(row,1));
defGrid.setGridCell(i,2,defGrid.getGridCell(row,2));
defGrid.setGridCell(i,3, defGrid.getGridCell(row,3));
defGrid.setGridCell(i,4,defGrid.getGridCell(row,4));
defGrid.setGridCell(i,5,defGrid.getGridCell(row,5));
//defGrid.setGridCell(i,6,"Allele No."+i);
}
defGrid.setRepaint(true);
}
private ScsGrid createDefGrid() {
int i, j;
ScsGrid grid = new com.scs.awt.ScsGrid();
grid.setName("DefGrid");
String columnSettings [] =
{"#|RIGHT|CENTER|15|false|true|false",
"Min|RIGHT|CENTER|50|false",
"Max|RIGHT|CENTER|50|false",
"Step|RIGHT|CENTER|50",
"Steps Number|RIGHT|CENTER|50",
"Default|RIGHT|CENTER|50",
"Name|LEFT|CENTER|150"};
grid.setColumnSettings(columnSettings);
grid.setNumberOfRows(8);
//grid.setRowGap(4);
grid.setRowSelectColor(Color.red);
grid.setBorderEffect(0);
grid.setBounds(26, 12, 526, 240);
grid.setGridTextFont(new Font("dialog", 1, 11));
grid.setNumberOfRows(8);
grid.setColumnGap(8);
grid.setCellSelection(true);
grid.setRowSelectFont(new Font("dialog", 1, 11));
grid.setGridTextColor(Color.blue);
grid.setRowHeight(13);
//grid.addCellListener(this);
for (i=0;i<problem.alleles.length;i++) {
grid.setGridCell(i,0,Integer.toString(i));
grid.setGridCell(i,1,String.valueOf(problem.alleles[i].min));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -