Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't get TSP example why there are update to cost/distance? #13

Open
bronzels opened this issue Jun 19, 2021 · 3 comments
Open

Don't get TSP example why there are update to cost/distance? #13

bronzels opened this issue Jun 19, 2021 · 3 comments

Comments

@bronzels
Copy link

bronzels commented Jun 19, 2021

I tried to write a problem myself by referring to TSP as it is easier to understand, but don't get what this function is for.

To me distance/cost is fixed to TSP problem, only variables for permutation to change as solution to evaluate the by 2 object, this update function is called for what reason and when?

jmetalsp-problem\src\main\java\org\uma\jmetalsp\problem\tsp\DynamicMultiobjectiveTSP.java

@OverRide
public void update(Observable<ObservedValue> observable, ObservedValue data) {
if (data!=null && data.getValue().getMatrixIdentifier() == "COST") {
updateCostValue(data.getValue().getX(),data.getValue().getY(),data.getValue().getValue());
} else if(data!=null && data.getValue().getMatrixIdentifier() == "VALUE"){
updateDistanceValue(data.getValue().getX(),data.getValue().getY(),data.getValue().getValue());
}
}

@bronzels
Copy link
Author

after more time spent on reading code, i got the idea of update is to use the streaming data source to add new cities or change connected/non-connected state between cities dynamically? but still i can't connect the dots:
1, if to add new cities, then why only distanceMatrix/costMatrix updated, numberOfCities remains same?
2, in updateDistanceValue/updateCostValue, why &&, should be || as a new city added, matric's x/y should be always 1 within length and another for new city is beyond length?
if (distanceMatrix.length < row && distanceMatrix[row].length < col) {

@bronzels
Copy link
Author

bronzels commented Jun 19, 2021

for adding new cities, besides adding into numberOfCities, also to call setNumberOfVariables to increase variables number? but is it feasible to add change variables in running state?

@cbarba
Copy link
Contributor

cbarba commented Jun 22, 2021

JMealSP only allows updating the distance matrix or the cost matrix, it is not possible to add more cities during the running time. The idea in the problem design is that due to different causes (traffic issues, accidents, etc) the values of both matrices can change. Then those changes must be reflected in the algorithm performance and data. However, the problem can be updated for allowing modifying the number of cities during the running time. Still, you need to consider that you need to include new matrices and ensure that they change the correct one and inside their boundaries.

The number of variables is set when the algorithm starts its execution and cannot be modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants