Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmlm committed Apr 18, 2012
2 parents 6b34c7e + 06f9da3 commit f17db46
Show file tree
Hide file tree
Showing 29 changed files with 605 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cluster/PowerMaster/build/built-jar.properties
@@ -1,4 +1,4 @@
#Thu, 12 Apr 2012 18:00:35 +0100 #Wed, 18 Apr 2012 11:32:43 +0100




C\:\\Users\\Bruno\\Documents\\NetBeansProjects\\PowerMaster= C\:\\Users\\Miranda\\Desktop\\PowerMaster=
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Cluster/PowerMaster/build/classes/Module/Loader/Loader.class
Binary file not shown.
Binary file modified Cluster/PowerMaster/build/classes/Module/Loader/OnesMax.class
Binary file not shown.
Binary file modified Cluster/PowerMaster/build/classes/Module/Loader/Problem.class
Binary file not shown.
Binary file not shown.
Binary file modified Cluster/PowerMaster/build/classes/NodeJS/NodeEmiter.class
Binary file not shown.
Binary file added Cluster/PowerMaster/build/classes/TMP/Item.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Cluster/PowerMaster/build/classes/powermaster/PowerMaster.class
Binary file not shown.
Binary file not shown.
Binary file modified Cluster/PowerMaster/dist/PowerMaster.jar
Binary file not shown.
17 changes: 14 additions & 3 deletions Cluster/PowerMaster/nbproject/build-impl.xml
Expand Up @@ -20,10 +20,10 @@ is divided into following sections:
--> -->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="PowerMaster-impl"> <project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="PowerMaster-impl">
<fail message="Please build using Ant 1.7.1 or higher."> <fail message="Please build using Ant 1.8.0 or higher.">
<condition> <condition>
<not> <not>
<antversion atleast="1.7.1"/> <antversion atleast="1.8.0"/>
</not> </not>
</condition> </condition>
</fail> </fail>
Expand Down Expand Up @@ -198,6 +198,7 @@ is divided into following sections:
<property name="javac.fork" value="${jdkBug6558476}"/> <property name="javac.fork" value="${jdkBug6558476}"/>
<property name="jar.index" value="false"/> <property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/> <property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
</target> </target>
<target name="-post-init"> <target name="-post-init">
Expand Down Expand Up @@ -384,6 +385,7 @@ is divided into following sections:
<property environment="env"/> <property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/> <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}"> <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/> <jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/> <jvmarg line="${profiler.info.jvmargs}"/>
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
Expand Down Expand Up @@ -514,7 +516,7 @@ is divided into following sections:
</chainedmapper> </chainedmapper>
</pathconvert> </pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}"/>
<manifest> <manifest>
<attribute name="Class-Path" value="${jar.classpath}"/> <attribute name="Class-Path" value="${jar.classpath}"/>
Expand Down Expand Up @@ -839,6 +841,14 @@ is divided into following sections:
--> -->
<target depends="init" if="have.sources" name="-javadoc-build"> <target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/> <mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
<and>
<isset property="endorsed.classpath.cmd.line.arg"/>
<not>
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
</not>
</and>
</condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath> <classpath>
<path path="${javac.classpath}"/> <path path="${javac.classpath}"/>
Expand All @@ -850,6 +860,7 @@ is divided into following sections:
<include name="**/*.java"/> <include name="**/*.java"/>
<exclude name="*.java"/> <exclude name="*.java"/>
</fileset> </fileset>
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
</javadoc> </javadoc>
<copy todir="${dist.javadoc.dir}"> <copy todir="${dist.javadoc.dir}">
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}"> <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
Expand Down
4 changes: 2 additions & 2 deletions Cluster/PowerMaster/nbproject/genfiles.properties
Expand Up @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.44.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=b694bb79 nbproject/build-impl.xml.data.CRC32=b694bb79
nbproject/build-impl.xml.script.CRC32=aaeadb6d nbproject/build-impl.xml.script.CRC32=e70e4baf
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
2 changes: 1 addition & 1 deletion Cluster/PowerMaster/nbproject/private/private.properties
Expand Up @@ -3,4 +3,4 @@ do.depend=false
do.jar=true do.jar=true
javac.debug=true javac.debug=true
javadoc.preview=true javadoc.preview=true
user.properties.file=C:\\Users\\Bruno\\.netbeans\\7.0\\build.properties user.properties.file=C:\\Users\\KopDicht\\.netbeans\\7.1\\build.properties
220 changes: 220 additions & 0 deletions Cluster/PowerMaster/src/Module/Loader/KnapSack.java
@@ -0,0 +1,220 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Module.Loader;

import TMP.Item;
import TMP.Mochila;
import genetics.Solver;
import java.util.ArrayList;

/**
*
* @author Bruno Oliveira nº 11127 IPT-ESTT
*/
public class KnapSack extends Problem {

public static final String ProblemName = "KnapSack";
/**
* Tamanho da população
*/
private int popSize;
public static final String PARAM_POPULATION_SIZE = "pop";
/**
* Tamanho do alelo
*/
private int alelloSize;
public static final String PARAM_ALELLO_SIZE = "alello";
/**
* Número maximo de Iterações
*/
private int Iterations;
public static final String PARAM_ITERATIONS = "iterations";
/**
* Condição de paragem. Melhor fitness individuo
*/
private int bestFitness;
public static final String PARAM_BEST_FITNESS = "best";
/**
* Capacidade maxima que a mochila pode contem
*/
private int maxWeight;
public static final String PARAM_MAX_WEIGHT="weight";
/**
* Valor maximo de peso que cada item pode ter
*/
private int maxItemWeight;
public static final String PARAM_MAX_ITEM_WEIGHT="max_item_weight";
/**
* Valor maximo de valor que cada item pode ter
*/
private int maxItemValue;
public static final String PARAM_MAX_ITEM_VALUE="max_item_value";
/**
* Número de items que existem no problema
*/
private int numItems;
public static final String PARAM_NUM_ITEMS="numItems";
/**
* Número de parametros que são necessário para que o problema OneMax seja corrido
*/
private static int PARAM_REQUIRED = 5;//Número de parametros obrigatórios
private int PARAM_ADDED = 0;//Número de parametros adicionados obrigatórios
private static int PARAM_COUNT = 8;//Número de parametros existentes no problema
/**
* Referência para todas as linhas existentes no documento
*/
private String data[];
/**
* Variável que indica o estado do loader
*/
private boolean loadStatus;
/**
* Estrutura de dados do problema
*/
private Mochila mochila;
/**
* Construtor do problema OnesMax
* @param data Informação do problema a ser carregado
*/
public KnapSack(String data[]) {
super(KnapSack.ProblemName, PARAM_COUNT);
this.data = data;
this.loadStatus = Load();
}

private boolean Load() {
System.out.println("----Params Data-----");
//Ler a segunda linha que contem todos os parametros de arranque
String[] parmsData = data[1].split(";");
//Percorrer todos os parametros
for (int i = 0; i < parmsData.length; i++) {
//Separar o identificado do valor (=)
String[] param = parmsData[i].split("=");
//Verificação de parametros
//parametro 1 (Obrigatório)
if (param[0].equals(KnapSack.PARAM_ITERATIONS) && !this.containsParam(KnapSack.PARAM_ITERATIONS)) {
//carregar o parametro para um dicionario de parametros
this.Iterations = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_ITERATIONS, this.Iterations);
//registar parametros obrigatório
this.PARAM_ADDED++;
System.out.println(KnapSack.PARAM_ITERATIONS+"+:"+this.PARAM_ITERATIONS);
continue;
}
//parametro 2
if (param[0].equals(KnapSack.PARAM_POPULATION_SIZE) && !this.containsParam(KnapSack.PARAM_POPULATION_SIZE)) {
this.popSize = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_POPULATION_SIZE, this.popSize);
//registar parametros obrigatório
this.PARAM_ADDED++;
System.out.println(KnapSack.PARAM_POPULATION_SIZE+"+:"+this.popSize);
continue;
}
//parametro 3
if (param[0].equals(KnapSack.PARAM_ALELLO_SIZE) && !this.containsParam(KnapSack.PARAM_ALELLO_SIZE)) {
this.alelloSize = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_ALELLO_SIZE, this.alelloSize);
//registar parametros obrigatório
this.PARAM_ADDED++;
System.out.println(KnapSack.PARAM_ALELLO_SIZE+"+:"+this.alelloSize);
continue;
}
//parametro 4
if (param[0].equals(KnapSack.PARAM_BEST_FITNESS) && !this.containsParam(KnapSack.PARAM_BEST_FITNESS)) {
this.bestFitness = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_BEST_FITNESS, this.bestFitness);
//registar parametros obrigatório
this.PARAM_ADDED++;
System.out.println(KnapSack.PARAM_BEST_FITNESS+"+:"+this.bestFitness);
continue;
}
//parametro 5
if (param[0].equals(KnapSack.PARAM_MAX_WEIGHT) && !this.containsParam(KnapSack.PARAM_MAX_WEIGHT)) {
this.maxWeight = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_MAX_WEIGHT, this.maxWeight);
//registar parametros obrigatório
this.PARAM_ADDED++;
System.out.println(KnapSack.PARAM_MAX_WEIGHT+"+:"+this.maxWeight);
continue;
}
//parametro 6
if (param[0].equals(KnapSack.PARAM_MAX_ITEM_WEIGHT) && !this.containsParam(KnapSack.PARAM_MAX_ITEM_WEIGHT)) {
this.maxItemWeight = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_MAX_ITEM_WEIGHT, this.maxItemWeight);
System.out.println(KnapSack.PARAM_MAX_ITEM_WEIGHT+":"+this.maxItemWeight);
continue;
}
//parametro 7
if (param[0].equals(KnapSack.PARAM_MAX_ITEM_VALUE) && !this.containsParam(KnapSack.PARAM_MAX_ITEM_VALUE)) {
this.maxItemValue = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_MAX_ITEM_VALUE, this.maxItemValue);
System.out.println(KnapSack.PARAM_MAX_ITEM_VALUE+":"+this.maxItemValue);
continue;
}
//parametro 8
if (param[0].equals(KnapSack.PARAM_NUM_ITEMS) && !this.containsParam(KnapSack.PARAM_NUM_ITEMS)) {
this.numItems = Integer.parseInt(param[1]);
this.addParam(KnapSack.PARAM_NUM_ITEMS, this.numItems);
System.out.println(KnapSack.PARAM_NUM_ITEMS+":"+this.numItems);
continue;
}
}
//Verificar se todos os parametros foram carregados
if (this.PARAM_ADDED >= KnapSack.PARAM_REQUIRED) {

//Verificar se na linha 2 do documento existe a tag de inicio de dados
if(this.data[2].equals("<DataStart>")){
//mochila = new Mochila(this.maxWeight);
int line=3;
//ArrayList<Item> values = new ArrayList<Item>();
System.out.println("-----DataStart-----");
//Enquanto for diferente que a tag de terminação de ficheiro vai adicionado
while(!this.data[line].trim().equals("<DataEnd>")){
//Ler o novo item
String[] item = this.data[line].split(";");
//adicionar o novo item
System.out.println(Integer.parseInt(item[0])+"-"+Integer.parseInt(item[1]));
//values.add(new Item(Integer.parseInt(item[0]), Integer.parseInt(item[1])));
//passar para a proxima linha
line++;
}
System.out.println("------DataEnd------");
return true;
}
return false;
}
return false;
}

/**
* Método que retorna o NOVO solver com os parametros carregados por o ficheiro.
* @return
*/
@Override
public Solver getNewSolver() {
//return new Solver(popSize, alelloSize, new genetics.OnesMax(), Iterations, bestFitness, new GeneticEvents(PowerMaster.INTERVAL_PART));
return null;
}

public boolean getStatus() {
return this.loadStatus;
}

public int getIterations() {
return Iterations;
}

public int getAlelloSize() {
return alelloSize;
}

public int getBestFitness() {
return bestFitness;
}

public int getPopSize() {
return popSize;
}
}
33 changes: 30 additions & 3 deletions Cluster/PowerMaster/src/Module/Loader/Loader.java
Expand Up @@ -4,31 +4,58 @@
*/ */
package Module.Loader; package Module.Loader;


import powermaster.VerificaParametros;

/** /**
* *
* @author Bruno Oliveira nº 11127 IPT-ESTT * @author Bruno Oliveira nº 11127 IPT-ESTT
*/ */
public class Loader { public class Loader {

static String[] linhas;

public static Problem Load(String dataIn) { public static Problem Load(String dataIn) {
//remover todos os caracteres estranhos //remover todos os caracteres estranhos
dataIn = dataIn.replace("\r", ""); dataIn = dataIn.replace("\r", "");
//Obter todas as linhas do documento //Obter todas as linhas do documento
String[] linhas = dataIn.split("\n"); linhas = dataIn.split("\n");
//Leitura da primeira linha para verificar qual o tipo de problema //Leitura da primeira linha para verificar qual o tipo de problema
String[] primeiraLinha = linhas[0].split(";"); String[] primeiraLinha = linhas[0].split(";");
//Verificação do tipo de problema (Linha 1) //Verificação do tipo de problema (Linha 1)
if (primeiraLinha[0].equals("OneMax")) {
if (primeiraLinha[0].equals(OnesMax.ProblemName) && VerificaParametros.VerInt(primeiraLinha)) {
System.out.println("##### New Ones Max Problem #####");
//Problema do tipo OnesMax //Problema do tipo OnesMax
OnesMax oneMax = new OnesMax(linhas); OnesMax oneMax = new OnesMax(linhas);
//Verificar se o objecto foi carregado com sucesso com a informação passada //Verificar se o objecto foi carregado com sucesso com a informação passada
if(oneMax.getStatus()){ if(oneMax.getStatus()){
//Atribnuição de Identificadores globais //Atribnuição de Identificadores globais
oneMax.setProblemID(Integer.parseInt(primeiraLinha[1])); oneMax.setProblemID(Integer.parseInt(primeiraLinha[1]));
oneMax.setClientID(Integer.parseInt(primeiraLinha[2])); oneMax.setClientID(Integer.parseInt(primeiraLinha[2]));
System.out.println("##### OnesMax Problem Ok #####");
return (Problem)oneMax; return (Problem)oneMax;
} }
System.out.println("##### OnesMax NOT LOADED #####");
} }
if (primeiraLinha[0].equals(KnapSack.ProblemName) && VerificaParametros.VerInt(primeiraLinha)) {
System.out.println("##### New KnapSack Problem #####");
//Problema do tipo OnesMax
KnapSack knapSack = new KnapSack(linhas);
//Verificar se o objecto foi carregado com sucesso com a informação passada
if(knapSack.getStatus()){
//Atribnuição de Identificadores globais
knapSack.setProblemID(Integer.parseInt(primeiraLinha[1]));
knapSack.setClientID(Integer.parseInt(primeiraLinha[2]));
System.out.println("##### KnapSack Problem Ok #####");
return (Problem)knapSack;
}
System.out.println("##### KnapSack NOT LOADED #####");
}

return null; return null;
} }





} }

0 comments on commit f17db46

Please sign in to comment.