Message Boards Message Boards

GROUPS:

My program keeps outputting the input! Help!

Posted 8 years ago
5371 Views
|
10 Replies
|
4 Total Likes
|
I'm trying to use mathematica to solve this linear integer program but I keep getting the input as the output.
I deleted like 9 lines of the constraints to make it fit to a page.
Attachments:
10 Replies
The Mathematica image posted is pretty much unusable. Post actual code.
Posted 8 years ago
  FindMinimum[{
  
    x10 + x14 + x18 + x112 + x116 + x20 + x24 + x28 + x212 + x216 +
  
     x30 + x34 + x38 + x312 + x316 + x40 + x44 + x48 + x412 + x416 +
  
     x50 + x54 + x58 + x512 + x516 + x60 + x64 + x68 + x612 + x616 +
  
     x70 + x74 + x78 + x712 + x716 + y140 + y144 + y148 + y1412 + y150 +
 
     y154 + y158 + y1512 + y250 + y254 + y258 + y2512 + y260 + y264 +
 
    y268 + y2612 + y360 + y364 + y368 + y3612 + y370 + y374 + y378 +
 
    y3712 + y470 + y474 + y478 + y4712,
 
   x10 + x40 + x50 + x60 + x70 + y140 + y150 + y370 + y470 >= 1,
 
   x10 + x20 + x50 + x60 + x70 + y140 + y150 + y250 + y260 >= 2,
 
   x10 + x20 + x30 + x60 + x70 + y250 + y260 + y360 + y370 >= 2,
 
   x10 + x20 + x30 + x40 + x70 + y130 + y360 + y370 + y470 >= 2,
 
   x10 + x20 + x30 + x40 + x50 + y140 + y150 + y250 + y360 >= 2,
 
   x20 + x30 + x40 + x50 + x60 + y150 + y250 + y260 + y360 >= 2,
 
   x30 + x40 + x50 + x60 + x70 + y260 + y360 + y370 + y470 >= 1,
 
   x40 + x44 + x10 + x14 + x50 + x54 + x60 + x64 + x70 + x74 + y140 +
 
     y144 + y150 + y154 + y370 + y374 + y470 + y474 >= 1,
 
   x10 + x14 + x50 + x54 + x24 + x20 + x60 + x64 + x70 + x74 + y140 +
 
     y144 + y150 + y154 + y250 + y254 + y260 + y264 >= 3,
 
   x10 + x14 + x24 + x20 + x30 + x34 + x70 + x74 + x60 + x64 + y250 +
 
     y254 + y260 + y264 + y360 + y364 + y370 + y374 >= 3,
 
   x10 + x70 + x74 + x14 + x24 + x20 + x30 + x34 + x40 + x44 + y140 +
 
     y144 + y360 + y364 + y370 + y374 + y470 + y474 >= 3,
 
   x10 + x24 + x20 + x30 + x34 + x40 + x44 + x50 + x54 + x14 + y140 +
 
     y144 + y150 + y154 + y250 + y254 + y470 + y474 >= 3,
 
   x20 + x24 + x30 + x34 + x40 + x44 + x50 + x54 + x60 + x64 + y150 +
 
     y154 + y250 + y260 + y254 + y264 + y360 + y364 >= 3,
 
   x30 + x34 + x40 + x44 + x50 + x54 + x60 + x64 + x70 + x74 + y260 +
 
     y264 + y360 + y364 + y370 + y374 + y470 + y474 >= 1,
 
   x44 + x48 + x14 + x18 + x54 + x58 + x64 + x68 + x74 + x78 + y140 +
 
     y144 + y148 + y150 + y154 + y158 + y370 + y374 + y378 + y470 +
 
     y474 + y478 >= 1,
 
   x14 + x18 + x24 + x54 + x58 + x28 + x64 + x68 + x74 + x78 + y140 +
 
     y144 + y148 + y150 + y154 + y158 + y250 + y254 + y258 + y260 +
 
     y264 + y268 >= 7,
 
   x14 + x18 + x24 + x28 + x34 + x38 + x74 + x78 + x64 + x68 + y250 +
 
     y254 + y258 + y260 + y264 + y268 + y360 + y364 + y368 + y370 +
 
     y374 + y378 >= 7,
 
   x14 + x18 + x24 + x28 + x34 + x38 + x44 + x48 + x74 + x78 + y140 +
 
     y144 + y148 + y360 + y364 + y368 + y370 + y374 + y378 + y470 +
 
     y474 + y478 >= 7,
 
   x24 + x28 + x34 + x38 + x44 + x48 + x54 + x58 + x14 + x18 + y140 +
 
     y144 + y148 + y150 + y154 + y158 + y250 + y254 + y258 + y470 +
 
     y474 + y478 >= 7,
 
   x24 + x28 + x34 + x38 + x44 + x48 + x54 + x58 + x64 + x68 + y150 +
 
     y154 + y158 + y260 + y250 + y254 + y258 + y264 + y268 + y360 +
 
     y364 + y368 >= 7,
 
   x34 + x38 + x44 + x48 + x54 + x58 + x64 + x68 + x74 + x78 + y260 +
 
     y264 + y268 + y360 + y364 + y368 + y370 + y374 + y378 + y470 +
 
     y474 + y478 >= 2,

  x48 + x412 + x18 + x112 + x58 + x512 + x68 + x612 + x78 + x712 +

    y144 + y148 + y1412 + y154 + y158 + y1512 + y374 + y378 + y3712 +

    y474 + y478 + y4712 >= 2,

  x18 + x58 + x512 + x112 + x28 + x212 + x68 + x612 + x78 + x712 +

    y144 + y148 + y1412 + y154 + y158 + y1512 + y254 + y258 + y2512 +

    y264 + y268 + y2612 >= 7,

  x18 + x68 + x612 + x112 + x28 + x212 + x38 + x312 + x78 + x712 +

    y254 + y258 + y2512 + y264 + y268 + y2612 + y364 + y368 + y3612 +

    y374 + y378 + y3712 >= 7,

  x18 + x112 + x28 + x212 + x38 + x312 + x48 + x412 + x78 + x712 +

    y144 + y148 + y1412 + y364 + y368 + y3612 + y374 + y378 + y3712 +

    y474 + y478 + y4712 >= 7,

  x28 + x212 + x38 + x312 + x48 + x412 + x58 + x512 + x18 + x112 +

    y144 + y148 + y1412 + y154 + y158 + y1512 + y254 + y258 + y2512 +

    y474 + y478 + y4712 >= 7,

  x28 + x212 + x38 + x312 + x48 + x412 + x58 + x512 + x68 + x612 +

    y154 + y158 + y1512 + y254 + y258 + y2512 + y264 + y268 + y2612 +

    y364 + y368 + y3612 >= 6,

  x38 + x312 + x48 + x412 + x58 + x512 + x68 + x612 + x78 + x712 +

    y264 + y268 + y2612 + y364 + y368 + y3612 + y374 + y378 + y3712 +

    y474 + y478 + y4712 >= 3,

  x412 + x416 + x112 + x512 + x612 + x712 + x116 + x516 + x616 +

    x716 + y148 + y1412 + y158 + y1512 + y378 + y3712 + y478 +

    y4712 >= 2,

  x512 + x516 + x112 + x212 + x612 + x712 + x116 + x216 + x616 +

    x716 + y148 + y1412 + y158 + y1512 + y258 + y2512 + y268 +

    y2612 >= 6,

  x612 + x616 + x112 + x212 + x312 + x712 + x116 + x216 + x316 +

    x716 + y258 + y2512 + y268 + y2612 + y368 + y3612 + y378 +

    y3712 >= 6,

  x112 + x212 + x312 + x412 + x116 + x216 + x316 + x416 + x712 +

    x716 + y148 + y1412 + y368 + y3612 + y378 + y3712 + y478 +

    y4712 >= 6,

  x212 + x312 + x412 + x512 + x216 + x316 + x416 + x516 + x112 +

    x116 + y148 + y1412 + y158 + y1512 + y258 + y2512 + y478 +

    y4712 >= 6,

  x212 + x216 + x312 + x412 + x512 + x612 + x316 + x416 + x516 +

    x616 + y158 + y1512 + y258 + y2512 + y268 + y2612 + y368 +

    y3612 >= 4,

  x312 + x316 + x412 + x512 + x612 + x712 + x416 + x516 + x616 +

    x716 + y268 + y2612 + y368 + y3612 + y378 + y3712 + y478 +

    y4712 >= 2,

  x116 + x516 + x616 + x716 + x416 + y1412 + y1512 + y3712 + y4712 >=

   2,

  x116 + x216 + x616 + x716 + x516 + y1412 + y1512 + y2512 + y2612 >=

   4,

  x116 + x216 + x316 + x716 + x616 + y2512 + y2612 + y3612 + y3712 >=

   4,

  x116 + x216 + x316 + x416 + x716 + y1412 + y3612 + y3712 + y4712 >=

   4,

  x116 + x216 + x316 + x416 + x516 + y1412 + y1512 + y2512 + y4712 >=

   4,

  x216 + x316 + x416 + x516 + x616 + y1512 + y2512 + y2612 + y3612 >=

   3,

  x316 + x416 + x516 + x616 + x716 + y2612 + y3612 + y3712 + y4712 >=

   1,

  x10 \[Element] Integers, x14 \[Element] Integers,

  x18 \[Element] Integers, x112 \[Element] Integers,

  x116 \[Element] Integers, x20 \[Element] Integers,

  x24 \[Element] Integers, x28 \[Element] Integers,

  x212 \[Element] Integers, x216 \[Element] Integers,

  x30 \[Element] Integers, x34 \[Element] Integers,

  x38 \[Element] Integers, x312 \[Element] Integers,

  x316 \[Element] Integers, x40 \[Element] Integers,

  x44 \[Element] Integers, x48 \[Element] Integers,

  x412 \[Element] Integers, x416 \[Element] Integers,

  x50 \[Element] Integers, x54 \[Element] Integers,

  x58 \[Element] Integers, x512 \[Element] Integers,

  x516 \[Element] Integers, x60 \[Element] Integers,

  x64 \[Element] Integers, x68 \[Element] Integers,

  x612 \[Element] Integers, x616 \[Element] Integers,

  x70 \[Element] Integers, x74 \[Element] Integers,

  x78 \[Element] Integers, x712 \[Element] Integers,

  x716 \[Element] Integers, y140 \[Element] Integers,

  y144 \[Element] Integers, y148 \[Element] Integers,

  y1412 \[Element] Integers, y150 \[Element] Integers,

  y154 \[Element] Integers, y158 \[Element] Integers,

  y1512 \[Element] Integers, y250 \[Element] Integers,

  y254 \[Element] Integers, y258 \[Element] Integers,

  y2512 \[Element] Integers, y260 \[Element] Integers,

  y264 \[Element] Integers, y268 \[Element] Integers,

  y2612 \[Element] Integers, y360 \[Element] Integers,

  y364 \[Element] Integers, y368 \[Element] Integers,

  y3612 \[Element] Integers, y370 \[Element] Integers,

  y374 \[Element] Integers, y378 \[Element] Integers,

  y3712 \[Element] Integers, y470 \[Element] Integers,

  y474 \[Element] Integers, y478 \[Element] Integers,

  y4712 \[Element] Integers},

{x10, x14, x18, x112, x116, x20, x24, x28, x212, x216, x30, x34, x38,

   x312, x316, x40, x44, x48, x412, x416, x50, x54, x58, x512, x516,

  x60, x64, x68, x612, x616, x70, x74, x78, x712, x716, y140, y144,

  y148, y1412, y150, y154, y158, y1512, y250, y254, y258, y2512, y260,

   y264, y268, y2612, y360, y364, y368, y3612, y370, y374, y378,

  y3712, y470, y474, y478, y4712}]
Posted 8 years ago
posted in reply
I changed FindMinimum to NMinimize and got an error message
NMinimize::bcons: The following constraints are not valid: {x10+x40+x50+x60+x70+y140+y150+y370+y470>=1,x10+x20+x50+x60+x70+y140+y150+y250+y260>=2,x10+x20+x30+x60+x70+y250+y260+y360+y370>=2,x10+x20+x30+x40+x70+y130+y360+y370+y470>=2,x10+x20+x30+x40+x50+y140+y150+y250+y360>=2,<<41>>,x116\Integers,x20\Integers,x24\Integers,x28\Integers,<<55>>}. Constraints should be equalities, inequalities, or domain specifications involving the variables. >>

Perhaps there's  variable in your constraints that not given in the list of variables at the end.
Posted 8 years ago
Thanks! I'm pretty new, does that say where to look?
Posted 8 years ago
Check to see if y130 is an error.
Check to see if there might be one too few y140.
Check to see if there might be one too many y360.
Check to see if there might be one too few y470. 
Each of those are just from counting how many times each variable appears.
Posted 8 years ago
updated below
If you decide to post more code - for such large samples please just attach notebook.
Posted 8 years ago
Attached updated code.

For some reason it says there there is no feasible answer, but for sure there is one if you have all variables as like 100. So i'm not sure what's wrong now..
Attachments:
Posted 8 years ago
Found a total of 15 with {
x10 -> 0, x14 -> 0, x18 -> 0, x112 -> 0, x116 -> 1, x20 -> 0,
 x24 -> 0, x28 -> 1, x212 -> 0, x216 -> 1, x30 -> 0, x34 -> 0,   x38 -> 1, x312 -> 0, x316 -> 0, x40 -> 0, x44 -> 0, x48 -> 0,
 x412 -> 0, x416 -> 0, x50 -> 0, x54 -> 0, x58 -> 0, x512 -> 0,   x516 -> 0, x60 -> 0, x64 -> 0, x68 -> 0, x612 -> 0, x616 -> 0,
 x70 -> 0, x74 -> 0, x78 -> 0, x712 -> 0, x716 -> 0, y140 -> 1,   y144 -> 1, y148 -> 1, y1412 -> 1, y150 -> 0, y154 -> 0, y158 -> 0,
 y1512 -> 0, y250 -> 1, y254 -> 0, y258 -> 1, y2512 -> 1, y260 -> 0,   y264 -> 1, y268 -> 0, y2612 -> 0, y360 -> 1, y364 -> 0, y368 -> 1,
 y3612 -> 1, y370 -> 0, y374 -> 0, y378 -> 0, y3712 -> 0, y470 -> 0,   y474 -> 0, y478 -> 0, y4712 -> 0}

You can modify the range of each variable, but with a few small changes I didn't find a smaller minimum.
Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract