10 Replies Latest reply on Mar 22, 2016 8:22 AM by disabled_ScottKoontz

    Simplex method in FileMaker

    marco_terrile

      Hi everybody, this is my first post in the new forum...

      (please excuse me for my bad english)

       

      The question is: did anybody deal with the Simplex Algorithm?

      The Simplex (not simple at all) created by G.B.Dantzig in 1947 is a linear programming method which makes possible to find an optimal solution among thousands of variables with hundreds of constraints in a limited number of iterations.

      i found some programs in c, visual basic and java which can solve these problems. It is embedded in Excel Solver function too...

      But i MUST to do it with FM (a required and necessary implementation in a solution :-( )

      The goal is to find the right combination of, let's say, some ingredients of a recipe. Each ingredient has contents of various components (sugar, proteins, fats and so on).

      Given a list of ingredients, a target (let's say 17% sugars, 6% fats, 10% proteins), and several constraints (i.e. ingredient A ≥ 10% and ≤ 30%; ingredient B ≥ 0% and ≤ 100%, ingredient C = 7%) the algorithm should give the amounts of the various ingredients to center the target, or at least get near to it...

      The interesting thing is that it makes it all in a limited number of iterations: very quick...

      I know it's a hard challenge.

      Did anybody try it?

       

      Bye

       

      marco

        • 1. Re: Simplex method in FileMaker
          psijmons

          hello Marco,

          I couldn't help you with the actual algorithm, but you are definintely heading for a CustomFunction to get this done (requires FMP Advanced).

          Have a look at http://www.briandunning.com/filemaker-custom-functions/recentlist.php to get a feel of all the things that are possible.

          Your visual basic or Java examples should give good clues how you can translate that into  a CustomFunction where [sugar] [fats] [protein] come in as parameters.

           

          If you get stuck, then post your issues (unless you want to keep this private) and you may get help when building the CF.

          • 2. Re: Simplex method in FileMaker
            marco_terrile

            Thank you psijmons,

            i know Brian Dunning site an already checked out the CF archive to find a possible answer to my simplex problem...

            I'll take another look to the last functions: maybe something new...

            At the moment i'm studying all the simplex examples on the math sites around the internet.

            Sure, a CF would be the best solution, but the simplex is not so easy: it will require more than a custom function to get rid of it... i fear.

             

            Thanks

            • 3. Re: Simplex method in FileMaker
              psijmons

              OK, I wasn't sure of your level of expertise in FMP.

              If you have a Java program available that does the Simplex algorithm, you may try to send an executable event from an FMP script and see if you can pickup the outcome or display it in a webviewer inside FMP.

              • 4. Re: Simplex method in FileMaker
                marco_terrile

                ...thanks for the hint, but it's not so simple.

                The whole thing is a bit more articulated: the solution is a packed runtime directed to ice cream makers. The level of the end user is very very low. They don't need to know anything about the simplex. They simply have to choose some ingredients, click a button and get the weights or percentages for each ingredient...

                So the calculations must be in background and passing data to a java external program doesn't seem to me a good way to follow :-(

                Anyway i appreciate your help!

                 

                Thanks again and happy new year!!!

                 

                Marco

                • 5. Re: Simplex method in FileMaker
                  DrewTenenholz

                  Marco --

                   

                  Take a look into the 360Works ScriptMaster plugin.

                   

                  1) It's free.

                  2) It can be distributed with a FileMaker runtime.

                  3) It uses a language called Groovy, which is Java-like.  It is surprising what you can paste into it and have it just work.

                   

                  One way the plug-in works is that you call it on file startup to load a function into FileMaker.  You can call it anything you like .  Then, when you want to use the function, it is there, just like a built-in FileMaker function.

                   

                  I'm pretty sure something like the simplex algorithm can be translated into Groovy.  I've been using hashing and AES encryption, which have some complexity themselves.  ScriptMaster makes this pretty easy.

                   

                  Good Luck!

                   

                  -- Drew Tenenholz

                   

                   

                  >The question is: did anybody deal with the Simplex Algorithm?

                  >The Simplex (not simple at all) created by G.B.Dantzig in 1947 is a linear programming method which makes possible to find an optimal solution among thousands of variables with hundreds of constraints in a limited number of iterations.

                  >i found some programs in c, visual basic and java which can solve these problems. It is embedded in Excel Solver function too...

                  >But i MUST to do it with FM (a required and necessary implementation in a solution   )

                  1 of 1 people found this helpful
                  • 6. Re: Simplex method in FileMaker
                    marco_terrile

                    Thanks a lot Drew, i didn'knew ScriptMaster. I read the documentation and found it very very interesting.

                    I'm going to download and try the plugin: it could be a good solution to my problem, and very useful for many other functions to add to custom solutions.

                     

                    Regards

                    marco

                    • 7. Re: Simplex method in FileMaker
                      btrammel52

                      Marco, how big will your linear system be? How many variables and constraints in a typical problem?

                      • 8. Re: Simplex method in FileMaker
                        marco_terrile

                        Hi btrammel52, the scenery: a typical recipe may have 6/10 ingredients. Each one of them has 4 parameters to be evalued, which are the contents of sugars, fats, proteins and solids. There are also two fields for min% and MAX% of use: these may bring two constraints into the simplex such as the type (family) of ingredient, which may be 1,2 or 3. The objective function is to reach in the recipe precise values in the composition in sugars, fats, proteins and solids. Let's say, I want a recipe with 18% sugars, 7% fats, 10% proteins and not more than 44% solids  (the remaining 36% will be water).

                        So there may be 42/70 variables and 18/30 constraints i guess...

                        The simplex should do the job...

                        At the moment i have a running VB version of the program and i'm translating the VB script into a series of FM scripts. So the subs and the functions of VB have been separated in single scripts.

                        I'm working with variables to try to keep it faster, but i have encountered a problem with matrix variables, as i can set as many repetitions i want in a FM variable, but only in one direction: an array... To store more values in each repetition i'm using a cf, in order to emulate the matrix. The cf is SetRep (rep;value) - from BrianDunning.com - , but still I have to test if it really works as i hope...

                        That's all folks !

                         

                        Bye

                        marco

                        • 9. Re: Simplex method in FileMaker
                          osmancabi@gmail.com

                          Hi Marco,


                          Is there any improvements on your solution?


                           

                          We are planning to use a FileMaker solution to solve some LP (at most 5-6 variables). Do you suggest doing such thing in FileMaker?

                           


                          Thank you,

                           

                          Osman Cabi

                          • 10. Re: Simplex method in FileMaker

                            I have a solution to this type of problem. Let me know if you are still interested in a FileMaker-Simplex solution.