{"id":25189034,"url":"https://github.com/yuricst/memoize-fmincon","last_synced_at":"2025-07-03T12:06:11.686Z","repository":{"id":129132693,"uuid":"410635029","full_name":"Yuricst/memoize-fmincon","owner":"Yuricst","description":"Memoized version of fmincon with MATLAB","archived":false,"fork":false,"pushed_at":"2021-09-26T19:04:43.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T10:16:38.154Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yuricst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-26T18:49:03.000Z","updated_at":"2023-04-22T16:36:16.000Z","dependencies_parsed_at":"2023-05-03T04:32:21.597Z","dependency_job_id":null,"html_url":"https://github.com/Yuricst/memoize-fmincon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Yuricst/memoize-fmincon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuricst%2Fmemoize-fmincon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuricst%2Fmemoize-fmincon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuricst%2Fmemoize-fmincon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuricst%2Fmemoize-fmincon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yuricst","download_url":"https://codeload.github.com/Yuricst/memoize-fmincon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yuricst%2Fmemoize-fmincon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263322822,"owners_count":23448717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T20:35:15.400Z","updated_at":"2025-07-03T12:06:11.655Z","avatar_url":"https://github.com/Yuricst.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memoize-fmincon\nMemoized version of fmincon with MATLAB\n\nThe `fmincon` function takes as input the objective and constraints functions as separate inputs; as such, if an expensive comptuation result is used in both expressions, it is preferable to keep use a single `fitness` function that comptutes both the objective and the constraints values. \nThe `memoized_fmincon()` function in this repo is a wrapper to `fmincon` that allows the user to pass a single `fitness` function and optimize.\n\n### Example\n\nThe fitness function must have the following signature:\n\n```MATLAB\nfunction [fval,gradf,c,ceq,gradc,gradceq] = fitness(x)\n  fval = (1-x(1))^2 + 100*(x(2) - x(1)^2)^2;  % objective\n\n  c(1,1) = (x(1) - 1)^3 - x(2) + 1;   % constraints\n  c(2,1) = x(1) + x(2) - 2;\n\n  ceq = [];\n\n  gradf = [];\n  gradc = [];\n  gradceq = [];\nend\n```\n\nNote that in this simple example, there are no shared terms within the computation of the obejctive and the constraints, so the memoization is not necessary. This simple example is rather intended to demonstrate the usage of the `memoized_fmincon()` function. \n\nThe main script should look as follows:\n\n```MATLAB\nclear; close all; clc;\n\nc = zeros(2,1);  % space for constraints\nx0 = rand(2,1);\n\nlb = [-1.5, -0.5];\nub = [1.5, 2.5];\nopts = optimoptions('fmincon','Display','iter','Algorithm','sqp');\n\n% run fmincon\n[u,fval,exitflag,output] = memoized_fmincon(@fitness, x0, lb, ub, opts);\n\nfprintf(\"Optimum x: %f, %f\\n\", u);\n```\n\nThis example is from `example_constrained.m`. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuricst%2Fmemoize-fmincon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuricst%2Fmemoize-fmincon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuricst%2Fmemoize-fmincon/lists"}