Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
29 changed files
with
605 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 modified
BIN
-73 Bytes
(99%)
Cluster/PowerMaster/build/classes/Module/Administration/AdministrationClient.class
Binary file not shown.
Binary file modified
BIN
-73 Bytes
(95%)
Cluster/PowerMaster/build/classes/Module/Administration/CommandThread.class
Binary file not shown.
Binary file modified
BIN
-73 Bytes
(93%)
Cluster/PowerMaster/build/classes/Module/Administration/GraphicThread.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+808 Bytes
(170%)
Cluster/PowerMaster/build/classes/Module/Loader/Loader.class
Binary file not shown.
Binary file modified
BIN
+907 Bytes
(140%)
Cluster/PowerMaster/build/classes/Module/Loader/OnesMax.class
Binary file not shown.
Binary file modified
BIN
+1.01 KB
(160%)
Cluster/PowerMaster/build/classes/Module/Loader/Problem.class
Binary file not shown.
Binary file modified
BIN
-73 Bytes
(97%)
Cluster/PowerMaster/build/classes/Module/WebHTTP/webServerSocket.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-97 Bytes
(96%)
Cluster/PowerMaster/build/classes/powermaster/GeneticEvents.class
Binary file not shown.
Binary file modified
BIN
+911 Bytes
(270%)
Cluster/PowerMaster/build/classes/powermaster/PowerMaster.class
Binary file not shown.
Binary file added
BIN
+1.22 KB
Cluster/PowerMaster/build/classes/powermaster/VerificaParametros.class
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.