-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSPSolution.java
More file actions
80 lines (71 loc) · 2.56 KB
/
Copy pathSSPSolution.java
File metadata and controls
80 lines (71 loc) · 2.56 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
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.aim.project.ssp.solution;
import com.aim.project.ssp.interfaces.SSPSolutionInterface;
import com.aim.project.ssp.interfaces.SolutionRepresentationInterface;
/**
* Represents a solution to the SSP, including the solution's representation
* and its associated objective function value. This class implements the SSPSolutionInterface.
*
* @author Sushant Nepal
* @since 17/03/2025
*/
public class SSPSolution implements SSPSolutionInterface {
private final SolutionRepresentationInterface oRepresentation; // The solution representation
private double iObjectiveFunctionValue; // The value of the objective function
/**
* Constructs a SSPSolution with the given solution representation and objective function value.
*
* @param oRepresentation The solution representation (tour) of locations.
* @param iObjectiveFunctionValue The objective function value for the solution.
*/
public SSPSolution(SolutionRepresentationInterface oRepresentation, double iObjectiveFunctionValue) {
this.oRepresentation = oRepresentation;
this.iObjectiveFunctionValue = iObjectiveFunctionValue;
}
/**
* Retrieves the objective function value of the solution.
*
* @return The objective function value.
*/
@Override
public double getObjectiveFunctionValue() {
return iObjectiveFunctionValue;
}
/**
* Sets the objective function value for the solution.
*
* @param objectiveFunctionValue The new objective function value.
*/
@Override
public void setObjectiveFunctionValue(double objectiveFunctionValue) {
this.iObjectiveFunctionValue = objectiveFunctionValue;
}
/**
* Retrieves the solution's representation, which stores the sequence of locations.
*
* @return The solution representation.
*/
@Override
public SolutionRepresentationInterface getSolutionRepresentation() {
return this.oRepresentation;
}
/**
* Creates a deep copy of the current solution, including the solution representation and objective function value.
*
* @return A new SSPSolution instance, which is a clone of the current solution.
*/
@Override
public SSPSolutionInterface clone() {
// Ensure deep cloning of the entire solution
return new SSPSolution(this.oRepresentation.clone(), this.iObjectiveFunctionValue);
}
/**
* Returns the total number of locations in the solution, including the hotel and airport.
*
* @return The total number of locations in the solution representation.
*/
@Override
public int getNumberOfLocations() {
// Delegate to the representation class to get the number of locations
return oRepresentation.getNumberOfLocations();
}
}