Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Dear all, many thanks for your comments. My OS is Windows 7. I will try to describe the program more in detail: - The overall idea is to simulate a production planing done in rolling schedule - The main routine is in Java. Here I generate test data that I export into a couple of.csv.-files. There is only a (public static void) main routine in Java, no other thread. For each csv.-file I do a .close Statement after finishing the writing. - After generating the .csv-files the routine calls a GLPK model (see the source code of my first post) - The GLPK model reads in the .csv-files and exports the solution into other .csv. files - Then the Java program reads in these csv. files, does some operations on the data and generates new output .csv files that are read in by GLPK and so on. After some iterations I get the mentioned error. Not always for the same .csv-file, sometimes also for a different one, and in a different iteration. This would indicate that Nigel is right. However, I could not detect other processes than my Java main routine (and other open programs like Eclispe) using the tool suggsted by Nigel. Do you have some further ideas on that? Martin Let us assume the OS is Windows in which case 113 means the system has run out of file handles. Normally you can open a file to read even if something else has it open for writing. I would suggest installing http://technet.microsoft.com/en-gb/sysinternals/bb896653 and observe which processes are opening so many files then fixing the code. -- Nigel Galloway nigel_gallo...@operamail.com On Tue, Jan 6, 2015, at 12:21 PM, Michael Hennebry wrote: On Tue, 6 Jan 2015, Martin Albrecht wrote: I am running a GLPK model that is sequentially started from a frame program in Java. In this contex, what is a frame program? What OS are you running? Unfortunately, I get sometime error when opening the .csv files. Here is an example: / csv_driver: unable to open BOM.csv - Permission denied allocation.mod:113: error on opening table tab_BOM glp_mpl_build_prob: invalid call sequence Error detected in file ..\src\glpapi14.c at line 93/ I do not get this error at each call of the Java model (one error after approx. 50 calls). Moreover, these errors do not occur in a deterministic manner, they cannot be reproduced. I each run of the Java program they occur at another place. Looks like a thread issue to me. Do the open and close occur in different threads? Perhaps the open is attempted before the close has gone through. -- michaelhenne...@web.cs.ndsu.nodak.edu "SCSI is NOT magic. There are *fundamental technical reasons* why it is necessary to sacrifice a young goat to your SCSI chain now and then." -- John Woods ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk -- http://www.fastmail.com - Same, same, but different... ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Let us assume the OS is Windows in which case 113 means the system has run out of file handles. Normally you can open a file to read even if something else has it open for writing. I would suggest installing http://technet.microsoft.com/en-gb/sysinternals/bb896653 and observe which processes are opening so many files then fixing the code. -- Nigel Galloway nigel_gallo...@operamail.com On Tue, Jan 6, 2015, at 12:21 PM, Michael Hennebry wrote: > On Tue, 6 Jan 2015, Martin Albrecht wrote: > > > I am running a GLPK model that is sequentially started from a frame program > > in Java. > > In this contex, what is a frame program? > What OS are you running? > > > Unfortunately, I get sometime error when opening the .csv files. > > Here is an example: > > / > > csv_driver: unable to open BOM.csv - Permission denied > > allocation.mod:113: error on opening table tab_BOM > > glp_mpl_build_prob: invalid call sequence > > Error detected in file ..\src\glpapi14.c at line 93/ > > > > I do not get this error at each call of the Java model (one error after > > approx. 50 calls). Moreover, these errors do not occur in a deterministic > > manner, they cannot be reproduced. I each run of the Java program they > > occur > > at another place. > > Looks like a thread issue to me. > Do the open and close occur in different threads? > Perhaps the open is attempted before the close has gone through. > > -- > Michael henne...@web.cs.ndsu.nodak.edu > "SCSI is NOT magic. There are *fundamental technical > reasons* why it is necessary to sacrifice a young > goat to your SCSI chain now and then." -- John Woods > > ___ > Help-glpk mailing list > Help-glpk@gnu.org > https://lists.gnu.org/mailman/listinfo/help-glpk -- http://www.fastmail.com - Same, same, but different... ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
On Tue, 6 Jan 2015, Martin Albrecht wrote: I am running a GLPK model that is sequentially started from a frame program in Java. In this contex, what is a frame program? What OS are you running? Unfortunately, I get sometime error when opening the .csv files. Here is an example: / csv_driver: unable to open BOM.csv - Permission denied allocation.mod:113: error on opening table tab_BOM glp_mpl_build_prob: invalid call sequence Error detected in file ..\src\glpapi14.c at line 93/ I do not get this error at each call of the Java model (one error after approx. 50 calls). Moreover, these errors do not occur in a deterministic manner, they cannot be reproduced. I each run of the Java program they occur at another place. Looks like a thread issue to me. Do the open and close occur in different threads? Perhaps the open is attempted before the close has gone through. -- Michael henne...@web.cs.ndsu.nodak.edu "SCSI is NOT magic. There are *fundamental technical reasons* why it is necessary to sacrifice a young goat to your SCSI chain now and then." -- John Woods ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Hi Heinrich, many thanks again for the fast answer. May I ask two further questions? - You mentioned that GLPK library is not thread safe. Do you think that the mentioned issue might persist if I change to data input via SQL? - Perhaps a "Anfängerfrage": I could not really use the documentation of Xpron. Is there a pdf Docu available? I would need an exemplary code written in Java. Thanks. Best regards Martin Am 06.01.2015 17:29, schrieb Heinrich Schuchardt: thread safe ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Hello Martin, an alternative way to import data is using SQL. If you look for an easier to program API to create the MIP on the fly have look at https://www.xypron.de/projects/linopt/ Please, remember that the GLPK library is not thread safe. Best regards Heinrich Schuchardt http://www.xypron.de Am 06.01.15 um 16:26 schrieb Martin Albrecht > Dear Heinrich, > > > > many thanks for the fast answer. > > > > In my Java code I always use the close() command after writing to the files. > > I have also restarted my computer to make sure that no instance of the > > file is blocked. > > > > The strange thing is that it works for some iterations (i.e. Java closes > > and GLPK open the files succesfully). > > And I cannot reproduce it. In different test runs of the same instance, > > the error may occur at different iterations. > > I also have aborted the program code directly after the error occurs. > > Then I open the model with Gusek. (I do not make any other changes such > > as closing an EXCEL file.) > > Here it can be solved without problems. > > > > May it be generally not recommended to do mass data exchange using .csv > > files with GLPK? > > Unfortunately, the Java interface is not very intuitive for me. I have > > to "see" the formulation in Gusek. I would have lots of difficulties > > with explicitly defining the rows and columns of the problem as it is > > necessary for using the Java interface. > > > > Best regards > > Martin > > > > > > > > Am 06.01.2015 12:49, schrieb Heinrich Schuchardt: > > > Heinrich Schuchardt ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Dear Heinrich, many thanks for the fast answer. In my Java code I always use the close() command after writing to the files. I have also restarted my computer to make sure that no instance of the file is blocked. The strange thing is that it works for some iterations (i.e. Java closes and GLPK open the files succesfully). And I cannot reproduce it. In different test runs of the same instance, the error may occur at different iterations. I also have aborted the program code directly after the error occurs. Then I open the model with Gusek. (I do not make any other changes such as closing an EXCEL file.) Here it can be solved without problems. May it be generally not recommended to do mass data exchange using .csv files with GLPK? Unfortunately, the Java interface is not very intuitive for me. I have to "see" the formulation in Gusek. I would have lots of difficulties with explicitly defining the rows and columns of the problem as it is necessary for using the Java interface. Best regards Martin Am 06.01.2015 12:49, schrieb Heinrich Schuchardt: Heinrich Schuchardt ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] csv_driver:unable to create ....csv - Permission denied
Hello Martin, please, check that the CSV file is not opened by an other program. Excel locks opened files. Same happens if Java opens a file for writing. The lock is kept until the file is closed. Best regards Heinrich Schuchardt http://www.xypron.de Am 06.01.15 um 11:53 schrieb Martin Albrecht > Dear all, > > > > I am running a GLPK model that is sequentially started from a frame > > program in Java. > > The frame program does the following: > > -It creates data files (.csv) that are read in by the GLPK model thereafter > > -The call of the GLPK model is according to the help documentation: > > > > /public void start() { > > > > glp_prob lp = null; > > glp_tran tran; > > glp_iocp iocp; > > > > int skip = 0; > > int ret; > > > > // GlpkCallback.addListener(this); > > > > lp = GLPK.glp_create_prob(); > > System.out.println("Problem created"); > > > > tran = GLPK.glp_mpl_alloc_wksp(); > > ret = GLPK.glp_mpl_read_model(tran, fname, skip); > > if (ret != 0) { > > GLPK.glp_mpl_free_wksp(tran); > > GLPK.glp_delete_prob(lp); > > throw new RuntimeException("Model file not found: " + > > fname); > > } > > > > // generate model > > GLPK.glp_mpl_generate(tran, null); > > // build model > > GLPK.glp_mpl_build_prob(tran, lp); > > // set solver parameters > > iocp = new glp_iocp(); > > GLPK.glp_init_iocp(iocp); > > iocp.setPresolve(GLPKConstants.GLP_ON); > > // solve model > > ret = GLPK.glp_intopt(lp, iocp); > > // postsolve model > > if (ret == 0) { > > GLPK.glp_mpl_postsolve(tran, lp, GLPKConstants.GLP_MIP); > > } > > // free memory > > GLPK.glp_mpl_free_wksp(tran); > > GLPK.glp_delete_prob(lp); > > > > } > > }/ > > > > The GKLP model writes some output tables (csv.), and the results are > > read in again by Java after terminating the optimization run, and so on. > > > > Unfortunately, I get sometime error when opening the .csv files. > > Here is an example: > > / > > csv_driver: unable to open BOM.csv - Permission denied > > allocation.mod:113: error on opening table tab_BOM > > glp_mpl_build_prob: invalid call sequence > > Error detected in file ..\src\glpapi14.c at line 93/ > > > > I do not get this error at each call of the Java model (one error after > > approx. 50 calls). Moreover, these errors do not occur in a > > deterministic manner, they cannot be reproduced. I each run of the Java > > program they occur at another place. > > > > Do you have any advice what I could do about that? > > > > Many thanks for your effort. > > > > Best regards > > Martin > > ___ > > Help-glpk mailing list > > Help-glpk@gnu.org > > https://lists.gnu.org/mailman/listinfo/help-glpk ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk
[Help-glpk] csv_driver:unable to create ....csv - Permission denied
Dear all, I am running a GLPK model that is sequentially started from a frame program in Java. The frame program does the following: -It creates data files (.csv) that are read in by the GLPK model thereafter -The call of the GLPK model is according to the help documentation: /public void start() { glp_prob lp = null; glp_tran tran; glp_iocp iocp; int skip = 0; int ret; // GlpkCallback.addListener(this); lp = GLPK.glp_create_prob(); System.out.println("Problem created"); tran = GLPK.glp_mpl_alloc_wksp(); ret = GLPK.glp_mpl_read_model(tran, fname, skip); if (ret != 0) { GLPK.glp_mpl_free_wksp(tran); GLPK.glp_delete_prob(lp); throw new RuntimeException("Model file not found: " + fname); } // generate model GLPK.glp_mpl_generate(tran, null); // build model GLPK.glp_mpl_build_prob(tran, lp); // set solver parameters iocp = new glp_iocp(); GLPK.glp_init_iocp(iocp); iocp.setPresolve(GLPKConstants.GLP_ON); // solve model ret = GLPK.glp_intopt(lp, iocp); // postsolve model if (ret == 0) { GLPK.glp_mpl_postsolve(tran, lp, GLPKConstants.GLP_MIP); } // free memory GLPK.glp_mpl_free_wksp(tran); GLPK.glp_delete_prob(lp); } }/ The GKLP model writes some output tables (csv.), and the results are read in again by Java after terminating the optimization run, and so on. Unfortunately, I get sometime error when opening the .csv files. Here is an example: / csv_driver: unable to open BOM.csv - Permission denied allocation.mod:113: error on opening table tab_BOM glp_mpl_build_prob: invalid call sequence Error detected in file ..\src\glpapi14.c at line 93/ I do not get this error at each call of the Java model (one error after approx. 50 calls). Moreover, these errors do not occur in a deterministic manner, they cannot be reproduced. I each run of the Java program they occur at another place. Do you have any advice what I could do about that? Many thanks for your effort. Best regards Martin ___ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk