+ Reply to Thread
Results 1 to 8 of 8

Trouble Coding a Constraint for Solver

  1. #1
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    8

    Trouble Coding a Constraint for Solver

    Hi everybody,

    This is my first post, so please let me know if I don't follow the forum conventions, but I think I've got it so here goes.

    I have a macro that is running solver to optimize routes. I have a set of rows set up with indices linked to drivetimes and time windows. I need solver to manipulate the indices so that the route time is under a limit, delivery windows are met, and there are no duplicate stops. I need it to be a macro because we're going to be running it with different data sets, but I know there is a feasible solution because I've found one myself manually for one of our sets, and when I have the solution input already into the variable cells and run solver, solver confirms my solution and presents no problems. If I don't have the solution already entered in, however, solver says it can not find a feasible solution.

    I suspect this is because the way I have set up my constraints won't allow solver any wiggle room without violating a constraint, but I don't know for sure.

    Does anyone have any suggestions?

    Thank you.
    Last edited by dmcmillon86; 09-30-2011 at 02:44 PM. Reason: Problem Solved

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Trouble Coding a Constraint for Solver

    Welcome to the forum.

    No one is going to be able to help you in the abstract. Post a workbook and explain clearly what you're trying to do in context.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trouble Coding a Constraint for Solver

    Here is my file. I'm sorry it is not well commented. I'm new to VBA and not very good at that. I removed some of the sheets with private company info, so the time window checks don't work on this version. I'm pretty sure that's not the problem, though. Basically I can't get solver to even try using the unique integer values in different orders.
    Attached Files Attached Files

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Trouble Coding a Constraint for Solver

    One thing I noticed. In the
    Public Function DISCSUM(MixRange As Range) As Double
    you need to add the line
    Please Login or Register  to view this content.
    Alf

  5. #5
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trouble Coding a Constraint for Solver

    Thank you, Alf
    That solved some other problems I was having.
    As for the solver problem, I switched to the Evolutionary solver and my problem was solved. Thank you everyone who checked out my issue and put thought into it.

  6. #6
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trouble Coding a Constraint for Solver

    Could you mark ny problem as solved?
    Asking you is the correct thing to do, rgiht?

    Thank you

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Trouble Coding a Constraint for Solver

    Could you mark ny problem as solved?
    Asking you is the correct thing to do, rgiht?
    No, you mark your problem solved yourself because you is the only person that can decide if your problem is solved. As to how to do it see quote from forum rules.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
    Alf

  8. #8
    Registered User
    Join Date
    09-13-2011
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Trouble Coding a Constraint for Solver

    Thank you, Alf

+ 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