0

I am new to Java, so, my question may be so simple for you. But I am trying to solve this issue for ages.

I am not writing my code. It is from MATSim. Their codes have two versions: one from 2009, and the other from 2013.

please see this screenshot:

If tis picture does not work please see it via tweeter: ScreenShot

I have downloaded the 2013 version and added its library according to the guidelines. BUT the code up in Eclipse is a code from 2009 and as you can see some of the classes needed for this code is removed from the 2013 library.

***>>>>>>For example, this one is not in the library:..... import org.matsim.core.scoring.PlanScorer;<<<<<<<<<<<***
import org.matsim.knowledges.Knowledges;
import org.matsim.locationchoice.constrained.LocationMutatorwChoiceSet;
import org.matsim.locationchoice.constrained.ManageSubchains;
import org.matsim.locationchoice.constrained.SubChain;
import org.matsim.planomat.Planomat;
import org.matsim.planomat.costestimators.DepartureDelayAverageCalculator;
import org.matsim.planomat.costestimators.LegTravelTimeEstimatorFactory;
import org.matsim.population.algorithms.PlanAlgorithm;

**>>>>>>> or these specific classes: ..... import playground.mfeil.MDSAM.ActivityTypeFinder;
import playground.mfeil.config.PlanomatXConfigGroup;<<<<<<<<<<**

Fortunately I found their .java files from their archive. I tried to put them in the .jar folder and add them to the library via >>> properties/Java Build Path. But this didn't work for me.

I wonder if you help me in this matter. Please if you know how to do it, help me in how to change the path of files in the above code too. Is it enough just to change the path manually?

Your help is much appreciated.

Thank you, Somayeh

Somayeh
  • 51
  • 8

2 Answers2

1

Guessing around from the information you gave...

Option A:

According to MATSim's issue tracker, planomat does not exist anymore. The preferred way of replanning is adding smaller strategies to the MATSim config that change only one dimension at a time (instead of the best-response planomat). Check out the latest MATSim user guide chapter 7 for the strategies available and how to use them. The user guide is shipped with the latest release.

Option B:

If you really need planomat, fetch an older MATSim build. Planomat should then be part of the MATSim core. So there is no need of adding the playground of mfeil to your build path. Again, I do not recommend this. The preferred way is option A.

Andreas
  • 127
  • 1
  • 1
  • 8
0

There is not really sufficient information here, so I'm going to guess a little bit about what you are doing and what the problem is. It is really helpful if you say "I got this error message at compile time (or runtime) and here it is, and then paste that into the post. Otherwise we're left guessing.

I think you have two versions of a library that you are trying to use from code that you did not write, and that the code uses one of the versions but you have the library for the other one. (Again, this is stuff you could put into questions to make them more complete "I have version 2009, there is another version from 2013...").

You should not need source code for the modules you do not have; in particular, it would be a bad idea to use source code just for those that aren't found in one version and the other version's library -- they are bound to be incompatible.

Java libraries are generally distributed as 'jar' files (extension of jar); I think your problem might be solved if you have a jar file for the library version being used and put it on a "classpath" so your compiler and runtime can find it.

We'll be happy to help you set a path to use a different version of the library, but you have to tell us how you're compiling. There are several popular IDEs (eclipse, IntelliJ, others) and the ol' command-line special. The setting of paths for these are all different.

arcy
  • 12,845
  • 12
  • 58
  • 103
  • Dear Arcy, thank you for your reply. I have not run the programme yet. Let's start from here, I am using Eclipse. I have added the 2013 library to the referenced library. I downloaded a 2009 code which I needed to use. But the issue was this code needed eleven classes from 2009 as a source to import, and they do not exist in the 2013 library. Fortunately, I found those classes. But I do not know how to add these eleven classes to the current library. – Somayeh Aug 04 '14 at 18:36
  • I tried to put them in a folder and import them as a second .jar source to the library but I think this is so simplistic. It should be more complicated than this because it didn't work for me. I am thinking maybe I add these eleven 2009-classes to my current package. – Somayeh Aug 04 '14 at 18:40
  • Then, call the classes in the code through this formula: for example: Activity activity = new Activity(); – Somayeh Aug 04 '14 at 18:41
  • But I have another problem, this way is only possible when I have the main method. Imagine if I have three classes in one package, how it is possible to call them through each other without using main method. Is it possible at all? Well, definitely this should be so simple for you. But my background is not programming. Thank you for helping me. – Somayeh Aug 04 '14 at 18:44
  • If your background is not programming, then you might do well to find someone who programs to help you with this. Usually you can't take a subset of modules from one version of a library and use them with a different version of the same library. If the code ever worked anywhere, then it was written to compile and run with a specific version of the library, and THAT version is the one you need. You need one or more .jar files that represent the correct version, and you will either need to get the correct version number from the docs or the author, or try each one in turn to see what works. – arcy Aug 04 '14 at 21:08
  • In eclipse, in the properties for the project, there is an entry for "java build path". In that screen is a way to add and remove jar files from the path; if they're in the project, then you use Add, if you want to add them from outside the project, use "Add External". – arcy Aug 04 '14 at 21:09