Skip to content
Snippets Groups Projects
Commit cbdb8e8a authored by Gianluca Mastrolonardo's avatar Gianluca Mastrolonardo
Browse files

ok

parent 56ec6daf
No related branches found
No related tags found
No related merge requests found
Showing
with 193 additions and 0 deletions
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Es1.iml" filepath="$PROJECT_DIR$/Es1.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/StrongTest" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/Test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.8.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../graphLib.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MODULE_DIR$/../../graphLib.jar!/doc" />
</JAVADOC>
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
import it.uniupo.graphLib.InOut;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*********
Algoritmi 2 - Lavinia Egidi
uso:
0) sistemare il nome del package
1) scaricare l'archivio instances_01_KP.zip e decomprimerlo
2) sistemare il PATH o spostare la cartella nella directory del progetto
(la stessa directory che contiene src)
3) In ogni test, per ogni istanza che si vuole provare
--indicare il tipo dell'istanza (nome directory): typename low-dimensional oppure large_scale
--indicare il nome del file
**********/
//package <nome package>;
public class testZainoPisinger {
private static final String PATH = "instances_01_KP/";
@Test
public void testEasypeasy() {
String typename = "low-dimensional";
String filename = "f1_l-d_kp_10_269";
String[] instance = InOut.readStringArray(PATH + typename + "/" + filename);
String[] params = instance[0].split(" ");
int n = Integer.parseInt(params[0]);
int cap = Integer.parseInt(params[1]);
int[] values = new int[n];
int[] vols = new int[n];
for (int i = 0; i < n; i++) {
String[] pieces = instance[i + 1].split(" ");
values[i] = Integer.parseInt(pieces[0]);
vols[i] = Integer.parseInt(pieces[1]);
}
Zaino zai = new Zaino(values, vols, cap);
int maxVal = Integer.parseInt(InOut.readString(PATH + typename + "-optimum/" + filename));
assertEquals(maxVal, zai.getMaxVal());
}
@Test
public void test1() {
String typename = "large_scale";
String filename = "knapPI_1_100_1000_1";
String[] instance = InOut.readStringArray(PATH + typename + "/" + filename);
String[] params = instance[0].split(" ");
int n = Integer.parseInt(params[0]);
int cap = Integer.parseInt(params[1]);
int[] values = new int[n];
int[] vols = new int[n];
for (int i = 0; i < n; i++) {
String[] pieces = instance[i + 1].split(" ");
values[i] = Integer.parseInt(pieces[0]);
vols[i] = Integer.parseInt(pieces[1]);
}
Zaino zai = new Zaino(values, vols, cap);
int maxVal = Integer.parseInt(InOut.readString(PATH + typename + "-optimum/" + filename));
assertEquals(maxVal, zai.getMaxVal());
}
}
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class testZaino {
@Test
void testCostructor() {
int[] vol = {1, 3, 2};
int[] val = {2, 3, 2};
int cap = 3;
Zaino myZaino = new Zaino(val, vol, cap);
Assertions.assertNotNull(myZaino);
}
@Test
void test3Obj() {
int[] vol = {1, 3, 2};
int[] val = {2, 3, 2};
int cap = 3;
Zaino myZaino = new Zaino(val, vol, cap);
System.out.println(myZaino.getMaxVal());
}
}
563647
\ No newline at end of file
54503
\ No newline at end of file
9147
\ No newline at end of file
110625
\ No newline at end of file
11238
\ No newline at end of file
276457
\ No newline at end of file
28857
\ No newline at end of file
90204
\ No newline at end of file
9052
\ No newline at end of file
1514
\ No newline at end of file
18051
\ No newline at end of file
1634
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment