+ Reply to Thread
Results 1 to 3 of 3

Solver VBA ignoring constraints

  1. #1
    Registered User
    Join Date
    04-24-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    43

    Solver VBA ignoring constraints

    Hi all,

    I'm having some problems with Solver in VBA. Eessentially, I'm finding that it is ignoring the constraints that I am placing on the solution. Here is the code:
    Please Login or Register  to view this content.
    The code should be finding a value for cell ..4028 that satisfies the constraint that it is as close as possible to -1.99, whilst also ensuring that another cell is 0. Often, I'm getting a solution that gives me >0, thus it seems as though the constraint is being ignored (I should add that finding a solution for which the value is 0 is possible in every case). I'm wondering whether the key issue is that the solver doesn't have enough time/No. of iterations to reach an acceptable solution, but I'm not sure how to optimise this (I tried playing around with the Solver options shown but it didn't make much difference. It's not that important that the result has to be exactly -1.99, +/- one decimal place is ok. If any one has any ideas I'd be very grateful.

    D

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Solver VBA ignoring constraints

    forgetting the code does solver work manually?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,810

    Re: Solver VBA ignoring constraints

    Often, I'm getting a solution that gives me >0,
    How much greater than 0? A lot of the time, it will return something not quite 0 due to the limitations of double precision arithmetic and the precision specified in the Solver model.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1