| Dear all, I created a model to solve a linear programming capital budgeting problem with Ruby (OPL): Maximize NPV of projects (x1…x5) by taking into account Budget and Resource constraints (c1, c2). Solution can only be 0 or 1. Example: Maximize: 928 x1 + 908 x2 + 801 x3 + 543 x4 + 944 x5 Constraints: c1: 398 x1 + 151 x2 + 129 x3 + 275 x4 + 291 x5 <= 800 c2: 111 x1 + 139 x2 + 56 x3 + 54 x4 + 123 x5 <= 200 Result is binary (0 or 1): x1 x2 x3 x4 x5 My code works correctly until a certain number of projects (maximum 29). If I use more than 29 Projects (x1 + x2 + .. + x30) the code crashes with the following result: glp_set_row_name: i = 1; row name too long Error detected in file glpapi01.c at line 441 Abort trap: 6 Since I would like to process a lot more in order to solve the problem I need to somehow change my setup. I can’t really imagine that this is a given maximum. Does anybody have encountered a similar problem and could point me into the right direction? Attached you’ll find my test code (working) with 20 Projects. Many thanks and best regards, Lukas |
require 'opl'
lp = maximize(
"1400x1 + 0x1 + 100x2 + 0x2 + 2620x3 + 0x3 + 100x4 + 0x4 + 100x5 + 0x5 + 100x6 + 0x6 + 100x7+ 0x7 + 100x8 + 0x8 + 100x9 + 0x9 + 1400x10 + 0x10 +1400x11 + 0x11 + 100x12 + 0x12 + 2620x13 + 0x13 + 100x14 + 0x14 + 100x15 + 0x15 + 100x16 + 0x16 + 100x17+ 0x17 + 100x18 + 0x18 + 100x19 + 0x19 + 100x20 + 5x20",
subject_to([
"400x1 + 2800x2 + 180x3 + 180x4 + 180x5 + 180x6 + 180x7 + 180x8 + 180x9 + 200x10 + 400x11 + 2800x12 + 180x13 + 180x14 + 180x15 + 180x16 + 180x17 + 180x18 + 180x19 + 200x20 <= 3380",
"0.0x1 + 0.0x2 + 1.5x3 + 0.0x4 + 0.0x5 + 0.0x6 + 0.0x7 + 0.0x8 + 0.0x9 + 0.0x10 + 2.1x11 + 1.0x12 + 2x13 + 1.0x14 + 1.2x15 + 2x16 + 3x17 + 1.5x18 + 1.9x19 + 0x20 <= 1.5",
"x1 >= 0",
"x2 >= 0",
"x3 >= 0",
"x4 >= 0",
"x5 >= 0",
"x6 >= 0",
"x7 >= 0",
"x8 >= 0",
"x9 >= 0",
"x10 >= 0",
"x11 >= 0",
"x12 >= 0",
"x13 >= 0",
"x14 >= 0",
"x15 >= 0",
"x16 >= 0",
"x17 >= 0",
"x18 >= 0",
"x19 >= 0",
"x20 >= 0"
],[
"BOOLEAN: x1",
"BOOLEAN: x2",
"BOOLEAN: x3",
"BOOLEAN: x4",
"BOOLEAN: x5",
"BOOLEAN: x6",
"BOOLEAN: x7",
"BOOLEAN: x8",
"BOOLEAN: x9",
"BOOLEAN: x10",
"BOOLEAN: x11",
"BOOLEAN: x12",
"BOOLEAN: x13",
"BOOLEAN: x14",
"BOOLEAN: x15",
"BOOLEAN: x16",
"BOOLEAN: x17",
"BOOLEAN: x18",
"BOOLEAN: x19",
"BOOLEAN: x20"
]
))puts lp.solution puts lp.objective.optimized_value
_______________________________________________ Help-glpk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-glpk
