-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionRepresentation.java
More file actions
67 lines (59 loc) · 2.08 KB
/
Copy pathSolutionRepresentation.java
File metadata and controls
67 lines (59 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.aim.project.ssp.solution;
import com.aim.project.ssp.interfaces.SolutionRepresentationInterface;
/**
* Represents a solution to the SSP, storing the sequence of locations in a tour.
* This class implements the SolutionRepresentationInterface and provides methods for getting,
* setting, and cloning the solution representation.
*
* @author Sushant Nepal
* @since 17/03/2025
*/
public class SolutionRepresentation implements SolutionRepresentationInterface {
private int[] aiSolutionRepresentation;
/**
* Constructs a SolutionRepresentation with the given solution representation.
*
* @param aiRepresentation An array representing the solution (tour) in terms of location indices.
*/
public SolutionRepresentation(int[] aiRepresentation) {
this.aiSolutionRepresentation = aiRepresentation;
}
/**
* Retrieves the solution representation, which is an array of location indices.
*
* @return The solution representation.
*/
@Override
public int[] getSolutionRepresentation() {
return aiSolutionRepresentation;
}
/**
* Sets the solution representation to a new array of location indices.
*
* @param aiSolutionRepresentation The new solution representation.
*/
@Override
public void setSolutionRepresentation(int[] aiSolutionRepresentation) {
this.aiSolutionRepresentation = aiSolutionRepresentation;
}
/**
* Returns the total number of locations in the solution representation, including the hotel and airport.
*
* @return The total number of locations in the representation.
*/
@Override
public int getNumberOfLocations() {
// Return the number of locations in the solution representation, including the hotel and airport
return aiSolutionRepresentation.length + 2;
}
/**
* Creates a deep copy of the current SolutionRepresentation.
*
* @return A new SolutionRepresentation instance, which is a clone of the current solution.
*/
@Override
public SolutionRepresentationInterface clone() {
// Create and return a deep copy of the solution representation
return new SolutionRepresentation(this.aiSolutionRepresentation.clone());
}
}