Re: [Help-glpk] Problem importing gnulpk-java files in java project
Hi, I think you only need to importor the following: import org.gnu.glpk.*; Example: import org.gnu.glpk.*; import java.io.FileInputStream; import java.util.Properties; public class glpkjava { public static void main(String[] args) { GlpkSolver solver = new GlpkSolver(); GlpkSolver solver2 = solver.readModel(SING1.mod,SING1.dat,SING1.sol); solver2.simplex(); solver2.printSol(solucion sing1.txt); } } Bye, Carlos 2010/1/20 Sana Jawad s...@algrintechnologies.com Hi, I have written a model in MathProg. Now I want to integrate it in my java application. I have followed the tutorial for java binding given in the doc folder of glpk-java-1.08. The problem is that in my java application I can only import these three files import org.gnu.glpk.GlpkSolver; import org.gnu.glpk.GlpkHookIFC; import org.gnu.glpk.GlpkSolverKktConditions; I am unable to import the following files: import org.gnu.glpk.GLPK; import org.gnu.glpk.GLPKConstants; import org.gnu.glpk.SWIGTYPE_p_double; import org.gnu.glpk.SWIGTYPE_p_int; import org.gnu.glpk.glp_prob; import org.gnu.glpk.glp_smcp; Can anyone please tell me that what could be wrong. Thanx. ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
[Help-glpk] Application crash due to assert in GLPK
Hi everybody, I have been using GLPK (version 4.38) for Java for almost one year now. I just encontered (for the first time, fortunately) an assert that crashed in GLPK and that killed my whole Java application. This assert is located glplib10.c, line 109: xassert(xlcmp(env-t_last, t) = 0); It seems to be a strange time problem, but I wonder if I can do something to prevent this error to occur once again in the future. Am I responsible for this error? Is there a way for me to be sure that I won't run into the error again? If not, can I catch this type of errors in my Java application in order to treat it appropriately? Thanks, Sylvain Fournier ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re [Help-glpk] variable object and deletions
Hello Yingjie To: Andrew Makhorin m...@gnu.org Subject: [Help-glpk] variable object and deletions Message-ID: 259296.1916...@web54207.mail.re2.yahoo.com From:Yingjie Lan lany...@yahoo.com Date:Mon, 18 Jan 2010 23:36:41 -0800 (PST) Hi, Suppose you would like to use a variable object (a C structure, or C++ class, or Python class, etc) to represent a column in GLPK, it is probably natural to let the variable object have an integer field called 'index', which is the index of this variable in the GLPK model (the API of GLPK use this index very often). But there is a problem: when you delete a variable, you must update all this field for all variables behind the deleted variable. I am also aware of another index, which is the name of each variable, but it is less efficient (probably OK if doing Python). I wonder if there is a more elegant way to implement a variable object that would significantly brings down the overhead involved with variable deletions. Similar problem can be proposed for constraints, of course, and I suspect the solution is similar too. Regards, Yingjie I assume this is during problem building and prior to loading the data into a GLPK problem object? For C++: What if you hold your columns in std::listColumn rather than std::vectorColumn? Easier to delete entries in the way you wish I would think. I haven't got any C++ books here, otherwise I would work this up a bit more. Berryhill will undoubtedly have some good suggestions on the design of optimization problem structures: Berryhill, John B. 2001. C++ scientific programming : computational recipes at a higher level John Wiley and Sons, New York, USA. ISBN 0-471-41210-4. hope this is on the right track Robbie --- Robbie Morrison PhD student -- policy-oriented energy system simulation Technical University of Berlin (TU-Berlin), Germany University email (redirected) : morri...@iet.tu-berlin.de Webmail (preferred) : rob...@actrix.co.nz [from IMAP client] ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] C++ throw instead of C exit
This looks fine from my perspective. System function 'abort' and not 'exit' as I wrote -- it was a while since I looked at the GLPK source. In case of application fatal error the GNU coding standards suggest to use abort rather than exit, because abort allows using a debugger. (Though most of errors detected by glpk api routines are not fatal.) I am in no great hurry to use this feature so it doesn't have to be in the next release. You may need to expand on the use of 'info' in the documentation (void* is not often used in C++). It is a magic cookie, i.e. a pointer, which one can use to pass some necessary information to the exit routine not using a static variable. Glp_error_hook needs to know nothing about such information, so 'void *' is a most appropriate type. ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
[Help-glpk] Modelling Advice Request - Project Tasks
I am modelling a project in which doing some tasks before others will save time. I think that the model is correct - but even though I have only entered the savings for 1 task into the objective function, it is taking too long to run. I believe that the problem lies in my before1 and before2 conditions, each of which contain 15^4=50625 modelling variables. These conditions are needed to enable the before[] variable, where before[a,b]=1 means that task a will be completed before task b. The variable position[] is working correctly (position[5]=3 means that task five will be done third). I could eliminate the huge amount of work being done in the before1 and before2 conditions if I could make use of these position variables. Could anyone advise me how I can achieve the following, please? * if position[a] position[b], then before[a,b] = 0 * if position[a] position[b], then before[a,b] = 1 Thanks for any suggestions! Model appended below: /* The project consists of 15 tasks. Completion of any of these tasks will save time on other tasks in the project as follows: Task 1 savings: 2 hours on task 2: 2 hours on task 4: 1 hours on task 9 Task 2 savings: 2 hours on task 1: 3 hours on task 15 Task 3 savings: 4 hours on task 1: 1 hours on task 5 Task 4 savings: 1 hours on task 1: 1 hours on task 3: 2 hours on task 5: 1 hours on task 10 Task 5 savings: 1 hours on task 2: 1 hours on task 10: 1 hours on task 13: 1 hours on task 14: 1 hours on task 15 Task 6 savings: 1 hours on task 4: 1 hours on task 8: 2 hours on task 11: 1 hours on task 15 Task 7 savings: 2 hours on task 2: 3 hours on task 15 Task 8 savings: 4 hours on task 5: 1 hours on task 11 Task 9 savings: 1 hours on task 2: 2 hours on task 3: 1 hours on task 11: 1 hours on task 13 Task 10 savings: 4 hours on task 11: 1 hours on task 15 Task 11 savings: 1 hours on task 1: 1 hours on task 3: 1 hours on task 8: 1 hours on task 10: 1 hours on task 12 Task 12 savings: 3 hours on task 1: 1 hours on task 4: 1 hours on task 11 Task 13 savings: 2 hours on task 3: 3 hours on task 12 Task 14 savings: 1 hours on task 3: 1 hours on task 6: 1 hours on task 7: 1 hours on task 8: 1 hours on task 12 Task 15 savings: 2 hours on task 6: 2 hours on task 12: 1 hours on task 13 */ var task{1..15, 1..15}, binary; s.t. task1{a in 1..15}: sum{b in 1..15} task[a, b] = 1; s.t. task2{b in 1..15}: sum{a in 1..15} task[a, b] = 1; var position{1..15}, = 0; s.t. position1{a in 1..15}: sum{b in 1..15} b * task[b,a] = position[a]; var before{1..15, 1..15}, binary; s.t. before1{a in 1..15, b in 1..15, c in 1..15, d in 1..15: b a and c != d}: before[c,d] + 1.5 = task[a,c] + task[b,d]; s.t. before2{a in 1..15, b in 1..15, c in 1..15, d in 1..15: a b and c != d}: before[c,d] + task[a,c] + task[b,d] = 2.5; var saving{1..15}, = 0; s.t. s1: saving[1] = 2 * before[1,2] + 2 * before[1,4] + before[1,9]; maximize savings: saving[1]; solve; for {a in 1..15} { for {b in 1..15: task[a,b] = 1} { printf %s. Task %s\n, a, b; } } for {a in 1..15, b in 1..15: before[a,b] = 0.5 and a != b}{ printf task %s is done before task %s\n, a, b; } for {a in 1..15} { printf Position of task %s: %s\n, a, position[a]; } printf \nTotal Savings: %s hours., saving[1]; end; _ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] Modelling Advice Request - Project Tasks
I solved your enclosed model in 350sec. using SCIP (Answer was 5 ) with no special settings. Some restrictions on the variables vectors that should sum to 1 ( I forgot what the nomenclature for those are) can definitely reduce that further. Cheers Kretch On Wed, Jan 20, 2010 at 4:01 PM, Tawny Owl tow_fo...@hotmail.com wrote: I am modelling a project in which doing some tasks before others will save time. I think that the model is correct - but even though I have only entered the savings for 1 task into the objective function, it is taking too long to run. I believe that the problem lies in my before1 and before2 conditions, each of which contain 15^4=50625 modelling variables. These conditions are needed to enable the before[] variable, where before[a,b]=1 means that task a will be completed before task b. The variable position[] is working correctly (position[5]=3 means that task five will be done third). I could eliminate the huge amount of work being done in the before1 and before2 conditions if I could make use of these position variables. Could anyone advise me how I can achieve the following, please? * if position[a] position[b], then before[a,b] = 0 * if position[a] position[b], then before[a,b] = 1 Thanks for any suggestions! Model appended below: /* The project consists of 15 tasks. Completion of any of these tasks will save time on other tasks in the project as follows: Task 1 savings: 2 hours on task 2: 2 hours on task 4: 1 hours on task 9 Task 2 savings: 2 hours on task 1: 3 hours on task 15 Task 3 savings: 4 hours on task 1: 1 hours on task 5 Task 4 savings: 1 hours on task 1: 1 hours on task 3: 2 hours on task 5: 1 hours on task 10 Task 5 savings: 1 hours on task 2: 1 hours on task 10: 1 hours on task 13: 1 hours on task 14: 1 hours on task 15 Task 6 savings: 1 hours on task 4: 1 hours on task 8: 2 hours on task 11: 1 hours on task 15 Task 7 savings: 2 hours on task 2: 3 hours on task 15 Task 8 savings: 4 hours on task 5: 1 hours on task 11 Task 9 savings: 1 hours on task 2: 2 hours on task 3: 1 hours on task 11: 1 hours on task 13 Task 10 savings: 4 hours on task 11: 1 hours on task 15 Task 11 savings: 1 hours on task 1: 1 hours on task 3: 1 hours on task 8: 1 hours on task 10: 1 hours on task 12 Task 12 savings: 3 hours on task 1: 1 hours on task 4: 1 hours on task 11 Task 13 savings: 2 hours on task 3: 3 hours on task 12 Task 14 savings: 1 hours on task 3: 1 hours on task 6: 1 hours on task 7: 1 hours on task 8: 1 hours on task 12 Task 15 savings: 2 hours on task 6: 2 hours on task 12: 1 hours on task 13 */ var task{1..15, 1..15}, binary; s.t. task1{a in 1..15}: sum{b in 1..15} task[a, b] = 1; s.t. task2{b in 1..15}: sum{a in 1..15} task[a, b] = 1; var position{1..15}, = 0; s.t. position1{a in 1..15}: sum{b in 1..15} b * task[b,a] = position[a]; var before{1..15, 1..15}, binary; s.t. before1{a in 1..15, b in 1..15, c in 1..15, d in 1..15: b a and c != d}: before[c,d] + 1.5 = task[a,c] + task[b,d]; s.t. before2{a in 1..15, b in 1..15, c in 1..15, d in 1..15: a b and c != d}: before[c,d] + task[a,c] + task[b,d] = 2.5; var saving{1..15}, = 0; s.t. s1: saving[1] = 2 * before[1,2] + 2 * before[1,4] + before[1,9]; maximize savings: saving[1]; solve; for {a in 1..15} { for {b in 1..15: task[a,b] = 1} { printf %s. Task %s\n, a, b; } } for {a in 1..15, b in 1..15: before[a,b] = 0.5 and a != b}{ printf task %s is done before task %s\n, a, b; } for {a in 1..15} { printf Position of task %s: %s\n, a, position[a]; } printf \nTotal Savings: %s hours., saving[1]; end; -- Not got a Hotmail account? Sign-up now - Freehttp://clk.atdmt.com/UKM/go/19780/direct/01/ ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re: Re [Help-glpk] variable object and deletions
Hi Robbie, Hi, Suppose you would like to use a variable object (a C structure, or C++ class, or Python class, etc) to represent a column in GLPK, it is probably natural to let the variable object have an integer field called 'index', which is the index of this variable in the GLPK model (the API of GLPK use this index very often). But there is a problem: when you delete a variable, you must update all this field for all variables behind the deleted variable. I am also aware of another index, which is the name of each variable, but it is less efficient (probably OK if doing Python). I wonder if there is a more elegant way to implement a variable object that would significantly brings down the overhead involved with variable deletions. Similar problem can be proposed for constraints, of course, and I suspect the solution is similar too. Regards, Yingjie I assume this is during problem building and prior to loading the data into a GLPK problem object? For C++: Yes, the index value is assigned at that time, when you add the column (variable) into the GLPK model. The deletion comes from the use case when you are modifying the model (some customized algorithms may need to delete some non-basic variables from the model). What if you hold your columns in std::listColumn rather than std::vectorColumn? Easier to delete entries in the way you wish I would think. OK. The position index of the column in the list is used to make calls to GLPK API routines. When you delete one column from your list (where you must also have deleted the same column from the GLPK model), the position of those columns after the deleted column in the list/model also changed (reduced by 1). How to efficiently keep track of this index change is my problem. I haven't got any C++ books here, otherwise I would work this up a bit more. Berryhill will undoubtedly have some good suggestions on the design of optimization problem structures: Berryhill, John B. 2001. C++ scientific programming : computational recipes at a higher level John Wiley and Sons, New York, USA. ISBN 0-471-41210-4. hope this is on the right track Thanks, Robbie. Will check it out when got a chance. Yingjie ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] Modelling Advice Request - Project Tasks
I solved your enclosed model in 350sec. using SCIP (Answer was 5 ) with no special settings. Seems NEOS SCIP can be hooked up to many different solvers (including GLPK), I wonder which solver are you using behind SCIP? * if position[a] position[b], then before[a,b] = 0 * if position[a] position[b], then before[a,b] = 1 Big-M: M = 15 - 1 given 15 tasks. position[b] - position[a] = M * before[a,b] position[a] - position[b] = M * before[b,a] before[a,b]+before[b,a] == 1 /* The project consists of 15 tasks. Completion of any of these tasks will save time on other tasks in the project as follows: Task 1 savings: 2 hours on task 2: 2 hours on task 4: 1 hours on task 9 Task 2 savings: 2 hours on task 1: 3 hours on task 15 Task 3 savings: 4 hours on task 1: 1 hours on task 5 Task 4 savings: 1 hours on task 1: 1 hours on task 3: 2 hours on task 5: 1 hours on task 10 Task 5 savings: 1 hours on task 2: 1 hours on task 10: 1 hours on task 13: 1 hours on task 14: 1 hours on task 15 Task 6 savings: 1 hours on task 4: 1 hours on task 8: 2 hours on task 11: 1 hours on task 15 Task 7 savings: 2 hours on task 2: 3 hours on task 15 Task 8 savings: 4 hours on task 5: 1 hours on task 11 Task 9 savings: 1 hours on task 2: 2 hours on task 3: 1 hours on task 11: 1 hours on task 13 Task 10 savings: 4 hours on task 11: 1 hours on task 15 Task 11 savings: 1 hours on task 1: 1 hours on task 3: 1 hours on task 8: 1 hours on task 10: 1 hours on task 12 Task 12 savings: 3 hours on task 1: 1 hours on task 4: 1 hours on task 11 Task 13 savings: 2 hours on task 3: 3 hours on task 12 Task 14 savings: 1 hours on task 3: 1 hours on task 6: 1 hours on task 7: 1 hours on task 8: 1 hours on task 12 Task 15 savings: 2 hours on task 6: 2 hours on task 12: 1 hours on task 13 */ can reduce the before[,] variables somehow, create variable pair: before[a,b] and before[b,a] only if task a, b are related in savings. Cheers, Yingjie ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk
Re: [Help-glpk] Modelling Advice Request - Project Tasks
Soplex, but the heavy MIP lifting is done by scup On Jan 20, 2010, at 17:05, Yingjie Lan lany...@yahoo.com wrote: I solved your enclosed model in 350sec. using SCIP (Answer was 5 ) with no special settings. Seems NEOS SCIP can be hooked up to many different solvers (including GLPK), I wonder which solver are you using behind SCIP? * if position[a] position[b], then before[a,b] = 0 * if position[a] position[b], then before[a,b] = 1 Big-M: M = 15 - 1 given 15 tasks. position[b] - position[a] = M * before[a,b] position[a] - position[b] = M * before[b,a] before[a,b]+before[b,a] == 1 /* The project consists of 15 tasks. Completion of any of these tasks will save time on other tasks in the project as follows: Task 1 savings: 2 hours on task 2: 2 hours on task 4: 1 hours on task 9 Task 2 savings: 2 hours on task 1: 3 hours on task 15 Task 3 savings: 4 hours on task 1: 1 hours on task 5 Task 4 savings: 1 hours on task 1: 1 hours on task 3: 2 hours on task 5: 1 hours on task 10 Task 5 savings: 1 hours on task 2: 1 hours on task 10: 1 hours on task 13: 1 hours on task 14: 1 hours on task 15 Task 6 savings: 1 hours on task 4: 1 hours on task 8: 2 hours on task 11: 1 hours on task 15 Task 7 savings: 2 hours on task 2: 3 hours on task 15 Task 8 savings: 4 hours on task 5: 1 hours on task 11 Task 9 savings: 1 hours on task 2: 2 hours on task 3: 1 hours on task 11: 1 hours on task 13 Task 10 savings: 4 hours on task 11: 1 hours on task 15 Task 11 savings: 1 hours on task 1: 1 hours on task 3: 1 hours on task 8: 1 hours on task 10: 1 hours on task 12 Task 12 savings: 3 hours on task 1: 1 hours on task 4: 1 hours on task 11 Task 13 savings: 2 hours on task 3: 3 hours on task 12 Task 14 savings: 1 hours on task 3: 1 hours on task 6: 1 hours on task 7: 1 hours on task 8: 1 hours on task 12 Task 15 savings: 2 hours on task 6: 2 hours on task 12: 1 hours on task 13 */ can reduce the before[,] variables somehow, create variable pair: before[a,b] and before[b,a] only if task a, b are related in savings. Cheers, Yingjie ___ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk