Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/libraries/llibreries.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fichero_tonto.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hola
Adeu
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 1 addition & 2 deletions practicaIA1.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="AIMA" level="project" />
<orderEntry type="library" name="Azamon" level="project" />
<orderEntry type="library" name="llibreries" level="project" />
</component>
</module>
11 changes: 11 additions & 0 deletions src/com/lluc/practicaIA1/AzamonGoalTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lluc.practicaIA1;

import aima.search.framework.GoalTest;

public class AzamonGoalTest implements GoalTest {

public boolean isGoalState(Object state){

return false;
}
}
11 changes: 11 additions & 0 deletions src/com/lluc/practicaIA1/AzamonHeuristicFunction1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lluc.practicaIA1;

import aima.search.framework.HeuristicFunction;

public class AzamonHeuristicFunction1 implements HeuristicFunction{
public double getHeuristicValue(Object o) {
Estado estado = (Estado) o;
return estado.heuristicoCoste();
//return estado.heuristicoCosteFelicidad();
}
}
11 changes: 11 additions & 0 deletions src/com/lluc/practicaIA1/AzamonHeuristicFunction2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lluc.practicaIA1;

import aima.search.framework.HeuristicFunction;

public class AzamonHeuristicFunction2 implements HeuristicFunction{
public double getHeuristicValue(Object o) {
Estado estado = (Estado) o;
//return estado.heuristicoCoste();
return estado.heuristicoCosteFelicidad();
}
}
42 changes: 42 additions & 0 deletions src/com/lluc/practicaIA1/AzamonSuccessorFunction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.lluc.practicaIA1;
import IA.Azamon.Paquetes;
import IA.Azamon.Transporte;
import IA.probTSP.ProbTSPBoard;
import aima.search.framework.Successor;
import aima.search.framework.SuccessorFunction;

import java.util.*;

public class AzamonSuccessorFunction implements SuccessorFunction {
public List getSuccessors(Object a) {
ArrayList retVal = new ArrayList();
Estado estado_actual = (Estado) a;
Paquetes paquetes = estado_actual.get_paquetes();
Transporte transporte = estado_actual.get_transporte();
for (int i = 0; i < paquetes.size(); i++) {
for (int j = i + 1; j < paquetes.size(); j++) {
Estado newState = new Estado(estado_actual);

if(newState.swap(i, j)){
//String S = ("INTERCAMBIO " + " " + i + " " + j + " " + newState.toStringSimple());
String S = ("INTERCAMBIO " + " " + i + " " + j + " " + newState.toString());
retVal.add(new Successor(S, newState));
}
}
}

for (int i = 0; i < paquetes.size(); ++i) {
for (int j = 0; j < transporte.size(); ++j) {
Estado newState = new Estado(estado_actual);
if(newState.moure_paquete(i, j)) {
//String S = "MOVIDO paquete: " + i + " a la oferta " + j + newState.toStringSimple();
String S = "MOVIDO paquete: " + i + " a la oferta " + j + newState.toString();
retVal.add(new Successor(S, newState));
}
}
}


return retVal;
}
}
43 changes: 43 additions & 0 deletions src/com/lluc/practicaIA1/AzamonSuccessorFunctionSA.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.lluc.practicaIA1;

import IA.Azamon.Paquetes;
import IA.Azamon.Transporte;
import IA.probTSP.ProbTSPBoard;
import IA.probTSP.ProbTSPHeuristicFunction;
import aima.search.framework.Successor;
import aima.search.framework.SuccessorFunction;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class AzamonSuccessorFunctionSA /*implements SuccessorFunction*/ {
public List getSuccessors(int npaq, Paquetes paquetes, Transporte transporte) {
ArrayList retVal = new ArrayList();
//ProbTSPHeuristicFunction TSPHF = new ProbTSPHeuristicFunction();
Random myRandom=new Random();
int i,j;

// Nos ahorramos generar todos los sucesores escogiendo un par de paquetes al azar

i=myRandom.nextInt(npaq);

do{
j=myRandom.nextInt(npaq);
} while (i==j);


//ProbTSPBoard newBoard = new ProbTSPBoard(board.getNCities(), board.getPath(), board.getDists());
Estado newState = new Estado();

if(newState.swap(i, j)) {

//double v = TSPHF.getHeuristicValue(newBoard);
String S = ("INTERCAMBIO " + " " + i + " " + j + " " + newState.toString());

retVal.add(new Successor(S, newState));
}

return retVal;
}
}
Loading