tuto_ecj_android
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tuto_ecj_android [2014/03/03 14:16] – [5. Print configuration data] Denis Pallez | tuto_ecj_android [2014/03/03 15:05] – Denis Pallez | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | + | ||
- | - [[# | + | |
- | - [[# | + | |
- | - [[# | + | |
- | - [[# | + | |
- | - [[# | + | |
- | - [[# | + | |
- | - [[# | + | |
===== 1. Installation of Eclispe and Android SDK ===== | ===== 1. Installation of Eclispe and Android SDK ===== | ||
Line 43: | Line 34: | ||
Now, to get the all data in " | Now, to get the all data in " | ||
- | < | + | < |
InputStream configStream = null; | InputStream configStream = null; | ||
try { | try { | ||
Line 56: | Line 47: | ||
If your configuration file is named " | If your configuration file is named " | ||
It only remains to transfer the InputStream " | It only remains to transfer the InputStream " | ||
- | < | + | < |
ParameterDatabase paramDB = null; | ParameterDatabase paramDB = null; | ||
try { | try { | ||
Line 67: | Line 58: | ||
Now, you could run your evolutionary algorithm with the code below (more details are given in the ECJ manual, page 44) | Now, you could run your evolutionary algorithm with the code below (more details are given in the ECJ manual, page 44) | ||
- | < | + | < |
EvolutionState evaluatedState = Evolve.initialize(paramDB, | EvolutionState evaluatedState = Evolve.initialize(paramDB, | ||
evaluatedState.startFresh(); | evaluatedState.startFresh(); | ||
Line 102: | Line 93: | ||
===== 6. Write in a File with Android ===== | ===== 6. Write in a File with Android ===== | ||
- | However, ECJ may need a real File to run, and not an InputStream. For example, to initialize a population.\\ \\ In this part we'll see how to write a file.\\ As in the previous example you'll need a package named " | + | However, ECJ may need a real File to run, and not an InputStream. For example, to initialize a population. |
+ | |||
+ | In this part we'll see how to write a file. | ||
+ | As in the previous example you'll need a package named " | ||
+ | After, you'll need the context of you application : <code java>Context mContext = this; </ | ||
+ | Then, you have to load your file on your smartphone : <code java>File file = mContext.getFileStreamPath(" | ||
+ | Finaly, you can write into your file thanks to a FileWrite and a BufferedWriter : <code java> | ||
+ | FileWriter fileWriter = null; | ||
+ | try { | ||
+ | | ||
+ | } | ||
+ | catch (IOException e1) { | ||
+ | | ||
+ | } | ||
+ | BufferedWriter output = new BufferedWriter(fileWriter); | ||
+ | try { | ||
+ | | ||
+ | } | ||
+ | output.flush(); | ||
+ | catch (Exception e) { | ||
+ | | ||
+ | } | ||
+ | finally { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | As you can understand, this code write the text "Hello World" into the file " | ||
[[# | [[# | ||
Line 110: | Line 134: | ||
Now, you can use this file as in the previous [[# | Now, you can use this file as in the previous [[# | ||
- | But, as we said before, ECJ may need a file. Or more precisely, the path of this file.\\ For a population initialization, | + | But, as we said before, ECJ may need a file. Or more precisely, the path of this file.\\ For a population initialization, |
+ | < | ||
+ | pop.file = / | ||
+ | </ | ||
+ | Now, if you load " | ||
[[# | [[# | ||
Any questions or suggestions ? [[guegan@polytech.unice.fr; | Any questions or suggestions ? [[guegan@polytech.unice.fr; | ||
+ | |||
+ | < | ||
+ |
tuto_ecj_android.txt · Last modified: 2014/03/03 16:27 by Denis Pallez