Integer Programming Homework Assignment
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 5 of 5

Thread: Integer Programming Homework Assignment

  1. #1
    Join Date
    Apr 2013

    Integer Programming Homework Assignment


    For a linear programming assignment I have been asked to write a programme using VBA which can solve a linear programming problem with an additional constraint that all solutions must be integers.

    I have never used VBA before but I am following online tutorials and I am trying to learn at the moment. I have been given a Simplex algorithm written in Excel to work with.

    I was just wondering if anyone has any experience in this area and can recommend which Integer Programming Algorithm would be most appropriate to write using VBA? All of the algorithms I am reading about seem near impossible to programme (they seem to need a lot of human deduction), especially for a beginner.

    I'm sorry for asking such a general question. A small push in the right direction would help tremendously! I am using Retail 7.0.1627.

    Thank you very much for your time, it's truly appreciated.

  2. #2
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Integer Programming Homework Assignment

    I am not sure what you are looking for. If you input is integer then the only operation that would give a non integer would be division example 1/2

    I think you would need to explain what kind of problem you are trying to solve to get a good answer.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Chicago, IL

    Re: Integer Programming Homework Assignment

    You can record a MACRO using Excel, which IS actual VBA code (for Excel). Easy to modify or swap.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Apr 2013

    Re: Integer Programming Homework Assignment

    Hi Datamiser, my apologies for not being clear, thank you for your time. I am talking about a linear programming problem, with linear constraints.

    For example, find the maximum of Z = x1+x2+x3 for which the following constaints are satisfied: 3x1+4x2+x3 <= 20, x1+x2 <= 6, x1-x3 <= 2, x1 x2 x3 integers. (Random examples, probably give a poor solution). When solving this normally, it's possible to get the optimal solution whereby x1 and/or x2 and/or x3 are not integers. I am trying to find the best solution available where they are all integers. For example, this is a production problem and you can't make/sell half a chair. I am trying to write a VBA code with say ten macros going through this process. Excel is able to do this using the solver command but we have to write our own solver.

    Thank you dglienna, I will definitely look into that, it should help a lot with my learning!

    I thought that perhaps this was a common VBA exercise but I think now that it is rather specific to linear programming courses only. I will keep trying things out and hopefully one day reach the solution. Thank you for your time and advice and apologies for asking a poor question.

    Best wishes.

  5. #5
    Join Date
    Aug 2009
    NW USA

    Re: Integer Programming Homework Assignment

    Can you hard code the polynomials or is it supposed to take those as input? If you can hardcode then create an N dimensional array of all integers (with a reasonable limit):
    (0,0,2) . . . etc.
    run them through the constraint polys and collect the set of "pairs" that work. Then run these pairs through the optimization poly to see which one produces the max.

    This is kind of knuckle dragging but it may work. I don't know the level of the class so I am not sure of the sophistication expectations.
    Last edited by Mur16; April 16th, 2013 at 03:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center