@@ -18,7 +18,6 @@ import eva2.server.go.strategies.EvolutionStrategies;
|
|||||||
import eva2.server.go.strategies.GeneticAlgorithm;
|
import eva2.server.go.strategies.GeneticAlgorithm;
|
||||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||||
import eva2.server.modules.GOParameters;
|
import eva2.server.modules.GOParameters;
|
||||||
import eva2.tools.TokenHolder;
|
|
||||||
import eva2.tools.jproxy.ThreadProxy;
|
import eva2.tools.jproxy.ThreadProxy;
|
||||||
import eva2.tools.math.RNG;
|
import eva2.tools.math.RNG;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
@@ -524,7 +523,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
if (false) {
|
if (false) {
|
||||||
InterfaceGOStandalone app = (InterfaceGOStandalone)ThreadProxy.newInstance(new GOStandaloneVersion());
|
InterfaceGOStandalone app = (InterfaceGOStandalone)ThreadProxy.newInstance(new GOStandaloneVersion());
|
||||||
new TokenHolder("streiche", "");
|
|
||||||
app.startExperiment();
|
app.startExperiment();
|
||||||
app.setShow(false);
|
app.setShow(false);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,147 +0,0 @@
|
|||||||
package eva2.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Title: EvA2
|
|
||||||
* Description:
|
|
||||||
* Copyright: Copyright (c) 2003
|
|
||||||
* Company: University of Tuebingen, Computer Architecture
|
|
||||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
|
||||||
* @version: $Revision: 10 $
|
|
||||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
|
||||||
* $Author: streiche $
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*==========================================================================*
|
|
||||||
* IMPORTS
|
|
||||||
*==========================================================================*/
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TokenHolder extends Thread
|
|
||||||
{
|
|
||||||
//~ Instance fields ////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
private String m_account;
|
|
||||||
private String m_passwd = "";
|
|
||||||
private boolean m_wait = true;
|
|
||||||
|
|
||||||
//~ Constructors ///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public TokenHolder(String acc, String passw)
|
|
||||||
{
|
|
||||||
m_account = acc;
|
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
|
||||||
|
|
||||||
//System.out.println("passwd:");
|
|
||||||
m_passwd = passw;
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// m_passwd = in.readLine();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// System.out.println(""+e.getMessage());
|
|
||||||
// }
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
//~ Methods ////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getExecOutput(String command)
|
|
||||||
{
|
|
||||||
String Out = new String();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
BufferedReader in = null;
|
|
||||||
Process pro = null;
|
|
||||||
//System.out.println("Calling the command:" + command);
|
|
||||||
pro = Runtime.getRuntime().exec(command);
|
|
||||||
in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
|
|
||||||
|
|
||||||
String line = null;
|
|
||||||
|
|
||||||
while ((line = in.readLine()) != null)
|
|
||||||
{
|
|
||||||
System.out.println(line);
|
|
||||||
Out = Out + line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
//System.out.println("Error in calling the command:" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static void main(String[] x)
|
|
||||||
{
|
|
||||||
TokenHolder holder = new TokenHolder("ulmerh", "bal");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
String s = getExecOutput("tokens");
|
|
||||||
//System.out.println("-->tokens " + s);
|
|
||||||
s = getExecOutput("klog -principal " + m_account + " -password " +
|
|
||||||
m_passwd);
|
|
||||||
|
|
||||||
//System.out.println("-->klog "+s);
|
|
||||||
s = getExecOutput("tokens");
|
|
||||||
|
|
||||||
//System.out.println("-->tokens "+s);
|
|
||||||
m_wait = true;
|
|
||||||
|
|
||||||
while (m_wait == true)
|
|
||||||
{
|
|
||||||
//System.out.println(System.currentTimeMillis());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
double min = 360;
|
|
||||||
sleep(((long) (1000 * 60 * min)));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
//System.out.println("" + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
s = getExecOutput("klog -principal " + m_account + " -password " +
|
|
||||||
m_passwd);
|
|
||||||
|
|
||||||
//System.out.println("-->klog "+s);
|
|
||||||
s = getExecOutput("tokens");
|
|
||||||
//System.out.println("-->tokens " + s);
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println("Tokenholder finished !!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void stoprun()
|
|
||||||
{
|
|
||||||
m_wait = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// END OF FILE.
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,17 +1,20 @@
|
|||||||
package eva2.tools;
|
package eva2.tools;
|
||||||
|
|
||||||
|
import eva2.gui.BeanInspector;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eva2.gui.BeanInspector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of miscellaneous static helper methods.
|
* Collection of miscellaneous static helper methods.
|
||||||
*
|
*
|
||||||
* @author mkron
|
* @author mkron
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ToolBox {
|
public final class ToolBox {
|
||||||
|
/**
|
||||||
|
* Private constructor to prevent instances of module class.
|
||||||
|
*/
|
||||||
|
private ToolBox() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert all items of an enum to a String array and append the given String array at the end.
|
* Convert all items of an enum to a String array and append the given String array at the end.
|
||||||
@@ -22,10 +25,15 @@ public class ToolBox {
|
|||||||
public static String[] appendEnumAndArray(Enum<?> e, String[] additionals) {
|
public static String[] appendEnumAndArray(Enum<?> e, String[] additionals) {
|
||||||
Enum<?>[] fields = e.getClass().getEnumConstants();
|
Enum<?>[] fields = e.getClass().getEnumConstants();
|
||||||
int enumLen = fields.length; //values().length;
|
int enumLen = fields.length; //values().length;
|
||||||
int len = enumLen+additionals.length;
|
int len = enumLen + additionals.length;
|
||||||
String[] ret = new String[len];
|
String[] ret = new String[len];
|
||||||
for (int i=0; i<enumLen; i++) ret[i]=fields[i].toString();
|
for (int i = 0; i < enumLen; i++) {
|
||||||
for (int i=enumLen; i<ret.length; i++) ret[i] = additionals[i-enumLen];
|
ret[i] = fields[i].toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = enumLen; i < ret.length; i++) {
|
||||||
|
ret[i] = additionals[i - enumLen];
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,34 +44,34 @@ public class ToolBox {
|
|||||||
* @param strArr2
|
* @param strArr2
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String[] appendArrays(String[] strArr1,
|
public static String[] appendArrays(String[] strArr1, String[] strArr2) {
|
||||||
String[] strArr2) {
|
if (strArr1 == null) {
|
||||||
if (strArr1==null) return strArr2;
|
return strArr2;
|
||||||
if (strArr2==null) return strArr1;
|
}
|
||||||
|
if (strArr2 == null) {
|
||||||
|
return strArr1;
|
||||||
|
}
|
||||||
String[] ret = new String[strArr1.length + strArr2.length];
|
String[] ret = new String[strArr1.length + strArr2.length];
|
||||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
||||||
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] appendArrays(String[] strArr1,
|
public static String[] appendArrays(String[] strArr1, String str) {
|
||||||
String str) {
|
String[] ret = new String[strArr1.length + 1];
|
||||||
String[] ret = new String[strArr1.length+1];
|
|
||||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
||||||
ret[ret.length-1]=str;
|
ret[ret.length - 1] = str;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] appendArrays(Object[] objArr1,
|
public static Object[] appendArrays(Object[] objArr1, Object o) {
|
||||||
Object o) {
|
|
||||||
Object[] ret = new Object[objArr1.length + 1];
|
Object[] ret = new Object[objArr1.length + 1];
|
||||||
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
||||||
ret[ret.length-1]=o;
|
ret[ret.length - 1] = o;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] appendArrays(Object[] objArr1,
|
public static Object[] appendArrays(Object[] objArr1, Object[] objArr2) {
|
||||||
Object[] objArr2) {
|
|
||||||
Object[] ret = new Object[objArr1.length + objArr2.length];
|
Object[] ret = new Object[objArr1.length + objArr2.length];
|
||||||
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
||||||
System.arraycopy(objArr2, 0, ret, objArr1.length, objArr2.length);
|
System.arraycopy(objArr2, 0, ret, objArr1.length, objArr2.length);
|
||||||
@@ -96,11 +104,16 @@ public class ToolBox {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Double toDouble(Object o) {
|
public static Double toDouble(Object o) {
|
||||||
if (o instanceof Number) return ((Number)o).doubleValue();
|
if (o instanceof Number) {
|
||||||
else try {
|
return ((Number) o).doubleValue();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
Double d = Double.parseDouble(BeanInspector.toString(o));
|
Double d = Double.parseDouble(BeanInspector.toString(o));
|
||||||
return d;
|
return d;
|
||||||
} catch(Exception e) { }
|
} catch (Exception e) {
|
||||||
|
// Here be dragons!
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,8 +127,8 @@ public class ToolBox {
|
|||||||
*/
|
*/
|
||||||
public static Double[] parseDoubles(Object [] os) {
|
public static Double[] parseDoubles(Object [] os) {
|
||||||
Double[] vals = new Double[os.length];
|
Double[] vals = new Double[os.length];
|
||||||
for (int i=0; i<os.length; i++) {
|
for (int i = 0; i < os.length; i++) {
|
||||||
vals[i]=toDouble(os[i]);
|
vals[i] = toDouble(os[i]);
|
||||||
}
|
}
|
||||||
return vals;
|
return vals;
|
||||||
}
|
}
|
||||||
@@ -151,13 +164,19 @@ public class ToolBox {
|
|||||||
* @param cols the indices of columns in data to return
|
* @param cols the indices of columns in data to return
|
||||||
* @return a 2D double array containing the indexed columns from data
|
* @return a 2D double array containing the indexed columns from data
|
||||||
*/
|
*/
|
||||||
public static double[][] getCols(double[][] data, int ... cols) {
|
public static double[][] getCols(double[][] data, int... cols) {
|
||||||
if (data==null || (data[0]==null)) return null;
|
if (data == null || (data[0] == null)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
int nCols = cols.length;
|
int nCols = cols.length;
|
||||||
if (nCols>data[0].length) System.err.println("Error, mismatching column count in Mathematics.getCols!");
|
if (nCols > data[0].length) {
|
||||||
|
System.err.println("Error, mismatching column count in Mathematics.getCols!");
|
||||||
|
}
|
||||||
double[][] ret = new double[data.length][cols.length];
|
double[][] ret = new double[data.length][cols.length];
|
||||||
for (int i=0; i<data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
for (int j=0; j<cols.length; j++) ret[i][j] = data[i][cols[j]];
|
for (int j = 0; j < cols.length; j++) {
|
||||||
|
ret[i][j] = data[i][cols[j]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user