Is there a better way to make assignments for discrete placement? The Next CEO of Stack OverflowIs there a way to run Python on Android?What's the canonical way to check for type in Python?Nicest way to pad zeroes to a stringHow can I make a time delay in Python?Is there a way to substring a string?How to make a chain of function decorators?How to make a flat list out of list of lists?Proper way to declare custom exceptions in modern Python?Way to create multiline comments in Python?Most elegant way to check if the string is empty in Python?

How do I fit a non linear curve?

Physiological effects of huge anime eyes

TikZ: How to fill area with a special pattern?

What are the unusually-enlarged wing sections on this P-38 Lightning?

Why am I getting "Static method cannot be referenced from a non static context: String String.valueOf(Object)"?

Are the names of these months realistic?

Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne"

Can this note be analyzed as a non-chord tone?

How did Beeri the Hittite come up with naming his daughter Yehudit?

Audio Conversion With ADS1243

Is it OK to decorate a log book cover?

Can you teleport closer to a creature you are Frightened of?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

Won the lottery - how do I keep the money?

Does Germany produce more waste than the US?

Aggressive Under-Indexing and no data for missing index

Can I board the first leg of the flight without having final country's visa?

Which one is the true statement?

Where do students learn to solve polynomial equations these days?

What does "shotgun unity" refer to here in this sentence?

What would be the main consequences for a country leaving the WTO?

Is there an equivalent of cd - for cp or mv

Is French Guiana a (hard) EU border?

Free fall ellipse or parabola?



Is there a better way to make assignments for discrete placement?



The Next CEO of Stack OverflowIs there a way to run Python on Android?What's the canonical way to check for type in Python?Nicest way to pad zeroes to a stringHow can I make a time delay in Python?Is there a way to substring a string?How to make a chain of function decorators?How to make a flat list out of list of lists?Proper way to declare custom exceptions in modern Python?Way to create multiline comments in Python?Most elegant way to check if the string is empty in Python?










0















I'm trying to write a program to pair up some barges with some boats. Each barge has a certain volume. Each boat can hold up to 4 barges and push up to a certain total volume (varies by boat). The end goal is to use as few boats as possible while placing every barge.



I have tried using scipy.optimize.differential_evolution with various strategies and parameters and initial guesses. I just turn the numbers it spits out into integers so that they can be used to link to specific barges. After taking the args from the optimizer, the objective function does some work (not shown) and then sees if the conditions are satisfied and returns a value based on that. Here is some code that generally shows what I'm doing in the fobj (I don't include the full code because it is hard to understand without the structure of the classes I have set up etc):



bargeSpecsMet = True
boatSpecsMet = True
dumbBarge = 0
dumbBoat = 0

#sums up how many barges have either no assignment or more than 1 assignement
#each barge can only be in one place
for each in barges:
dumbBarge += abs(barge.numAssignments - 1)
if dumbBarge > 0:
bargeSpecsMet = False

#checks each boat to see if it over capacity
for each in boats:
if boats.totalBBLs > boats.maxBBLs:
boatSpecsMet = False
dumbBoat += 1

#returns a very large number based on how many barges aren't correct first
#does this until the barges have exactly 1 assignment each
if bargeSpecsMet == False:
return dumbBarge * 1e20

#returns a still large but smaller number based on how many boats are overcapacity
#does this until each barge is under capacity
if boatSpecsMet == False:
return dumbBoat * 1E10

#there will be more code for minimizing number of boats but i haven't gotten there yet


I used differential_evolution mainly because I'm familiar with it from using it on another project that minimized a more traditional math function. I don't think it's probably meant to be used for discrete placement of things but it sorta works. Unfortunately it doesn't want to stray far from my initial guesses. Does anyone have any tips for this? Is anyone familiar with another solver or method that would be better suited? I'm relatively new to python and also this kind of problem so I just don't know what I don't know is out there...



The only other method I've come up with so far is to brute force it by generating a combination of assignments, see if that works, if not rinse and repeat. I haven implemented it yet because I know that will take forever to find a solution.










share|improve this question


























    0















    I'm trying to write a program to pair up some barges with some boats. Each barge has a certain volume. Each boat can hold up to 4 barges and push up to a certain total volume (varies by boat). The end goal is to use as few boats as possible while placing every barge.



    I have tried using scipy.optimize.differential_evolution with various strategies and parameters and initial guesses. I just turn the numbers it spits out into integers so that they can be used to link to specific barges. After taking the args from the optimizer, the objective function does some work (not shown) and then sees if the conditions are satisfied and returns a value based on that. Here is some code that generally shows what I'm doing in the fobj (I don't include the full code because it is hard to understand without the structure of the classes I have set up etc):



    bargeSpecsMet = True
    boatSpecsMet = True
    dumbBarge = 0
    dumbBoat = 0

    #sums up how many barges have either no assignment or more than 1 assignement
    #each barge can only be in one place
    for each in barges:
    dumbBarge += abs(barge.numAssignments - 1)
    if dumbBarge > 0:
    bargeSpecsMet = False

    #checks each boat to see if it over capacity
    for each in boats:
    if boats.totalBBLs > boats.maxBBLs:
    boatSpecsMet = False
    dumbBoat += 1

    #returns a very large number based on how many barges aren't correct first
    #does this until the barges have exactly 1 assignment each
    if bargeSpecsMet == False:
    return dumbBarge * 1e20

    #returns a still large but smaller number based on how many boats are overcapacity
    #does this until each barge is under capacity
    if boatSpecsMet == False:
    return dumbBoat * 1E10

    #there will be more code for minimizing number of boats but i haven't gotten there yet


    I used differential_evolution mainly because I'm familiar with it from using it on another project that minimized a more traditional math function. I don't think it's probably meant to be used for discrete placement of things but it sorta works. Unfortunately it doesn't want to stray far from my initial guesses. Does anyone have any tips for this? Is anyone familiar with another solver or method that would be better suited? I'm relatively new to python and also this kind of problem so I just don't know what I don't know is out there...



    The only other method I've come up with so far is to brute force it by generating a combination of assignments, see if that works, if not rinse and repeat. I haven implemented it yet because I know that will take forever to find a solution.










    share|improve this question
























      0












      0








      0








      I'm trying to write a program to pair up some barges with some boats. Each barge has a certain volume. Each boat can hold up to 4 barges and push up to a certain total volume (varies by boat). The end goal is to use as few boats as possible while placing every barge.



      I have tried using scipy.optimize.differential_evolution with various strategies and parameters and initial guesses. I just turn the numbers it spits out into integers so that they can be used to link to specific barges. After taking the args from the optimizer, the objective function does some work (not shown) and then sees if the conditions are satisfied and returns a value based on that. Here is some code that generally shows what I'm doing in the fobj (I don't include the full code because it is hard to understand without the structure of the classes I have set up etc):



      bargeSpecsMet = True
      boatSpecsMet = True
      dumbBarge = 0
      dumbBoat = 0

      #sums up how many barges have either no assignment or more than 1 assignement
      #each barge can only be in one place
      for each in barges:
      dumbBarge += abs(barge.numAssignments - 1)
      if dumbBarge > 0:
      bargeSpecsMet = False

      #checks each boat to see if it over capacity
      for each in boats:
      if boats.totalBBLs > boats.maxBBLs:
      boatSpecsMet = False
      dumbBoat += 1

      #returns a very large number based on how many barges aren't correct first
      #does this until the barges have exactly 1 assignment each
      if bargeSpecsMet == False:
      return dumbBarge * 1e20

      #returns a still large but smaller number based on how many boats are overcapacity
      #does this until each barge is under capacity
      if boatSpecsMet == False:
      return dumbBoat * 1E10

      #there will be more code for minimizing number of boats but i haven't gotten there yet


      I used differential_evolution mainly because I'm familiar with it from using it on another project that minimized a more traditional math function. I don't think it's probably meant to be used for discrete placement of things but it sorta works. Unfortunately it doesn't want to stray far from my initial guesses. Does anyone have any tips for this? Is anyone familiar with another solver or method that would be better suited? I'm relatively new to python and also this kind of problem so I just don't know what I don't know is out there...



      The only other method I've come up with so far is to brute force it by generating a combination of assignments, see if that works, if not rinse and repeat. I haven implemented it yet because I know that will take forever to find a solution.










      share|improve this question














      I'm trying to write a program to pair up some barges with some boats. Each barge has a certain volume. Each boat can hold up to 4 barges and push up to a certain total volume (varies by boat). The end goal is to use as few boats as possible while placing every barge.



      I have tried using scipy.optimize.differential_evolution with various strategies and parameters and initial guesses. I just turn the numbers it spits out into integers so that they can be used to link to specific barges. After taking the args from the optimizer, the objective function does some work (not shown) and then sees if the conditions are satisfied and returns a value based on that. Here is some code that generally shows what I'm doing in the fobj (I don't include the full code because it is hard to understand without the structure of the classes I have set up etc):



      bargeSpecsMet = True
      boatSpecsMet = True
      dumbBarge = 0
      dumbBoat = 0

      #sums up how many barges have either no assignment or more than 1 assignement
      #each barge can only be in one place
      for each in barges:
      dumbBarge += abs(barge.numAssignments - 1)
      if dumbBarge > 0:
      bargeSpecsMet = False

      #checks each boat to see if it over capacity
      for each in boats:
      if boats.totalBBLs > boats.maxBBLs:
      boatSpecsMet = False
      dumbBoat += 1

      #returns a very large number based on how many barges aren't correct first
      #does this until the barges have exactly 1 assignment each
      if bargeSpecsMet == False:
      return dumbBarge * 1e20

      #returns a still large but smaller number based on how many boats are overcapacity
      #does this until each barge is under capacity
      if boatSpecsMet == False:
      return dumbBoat * 1E10

      #there will be more code for minimizing number of boats but i haven't gotten there yet


      I used differential_evolution mainly because I'm familiar with it from using it on another project that minimized a more traditional math function. I don't think it's probably meant to be used for discrete placement of things but it sorta works. Unfortunately it doesn't want to stray far from my initial guesses. Does anyone have any tips for this? Is anyone familiar with another solver or method that would be better suited? I'm relatively new to python and also this kind of problem so I just don't know what I don't know is out there...



      The only other method I've come up with so far is to brute force it by generating a combination of assignments, see if that works, if not rinse and repeat. I haven implemented it yet because I know that will take forever to find a solution.







      python python-3.x scipy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 17:33









      Ryan BoncheffRyan Boncheff

      11




      11






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068247%2fis-there-a-better-way-to-make-assignments-for-discrete-placement%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068247%2fis-there-a-better-way-to-make-assignments-for-discrete-placement%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived