{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Maxime Labonne",
  "title_listed": "The Art of Spending: Optimizing Your Marketing Budget with Nonlinear Optimization",
  "keywords": "非线性优化,CVXPY",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/the-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2/",
  "publish_date": "2023-05",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "0eb9877364ad",
  "collected_at": "2026-10-01T21:59:23",
  "title": "The Art of Spending: Optimizing Your Marketing Budget with Nonlinear Optimization | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n# The Art of Spending: Optimizing Your Marketing Budget with Nonlinear Optimization\nIntroduction to CVXPY to maximize marketing ROI\n[Maxime Labonne](https://towardsdatascience.com/author/mlabonne/)\nMay 22, 20239 min read\n# Optimize Your Marketing Budget with Nonlinear Programming\n![Image by author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1cQ5wZBXJLBvCOU_Vu1b-_A.jpeg)\nImage by author\nIn the age of digital marketing, businesses face the challenge of allocating their marketing budget across multiple channels to maximize sales.\nHowever, as they broaden their reach, these firms inevitably face the issue of **diminishing returns** - the phenomenon where additional investment in a marketing channel yields progressively smaller increases in conversions. This is where the concept of marketing budget allocation steps in, adding another layer of complexity to the whole process.\nIn this article, we're going to explore the potential of nonlinear programming, specifically conic optimization (or cone programming), as a tool for marketing budget allocation. With the use of this advanced mathematical technique, we aim to optimize the distribution of marketing budget across various platforms to extract the maximum value and the highest possible ROI.\nThe code is available on [GitHub](https://github.com/mlabonne/linear-programming-course/blob/main/4_Maximize_Your_Marketing_ROI_with_Nonlinear_Optimization.ipynb) and [Google Colab](https://colab.research.google.com/drive/1V7z8giemuTk92s_JMxIyr1Clr2TwY7xl?usp=sharing).\n## **💰 Marketing budget allocation**\nMarketing budget allocation is a critical aspect of any advertising campaign, requiring businesses to strategically distribute their resources across different channels. The goal is to maximize the effectiveness of their marketing efforts and achieve the highest possible return on investment (ROI). To tackle this challenge, we need to consider three key components:\n  1. **Attribution** : How can we connect conversion events to specific campaigns?\n  2. **Performance Estimation** : How can we predict the performance of a campaign based on its allocated budget?\n  3. **Optimization** : How can we allocate budgets across various campaigns to maximize ROI?\n\n\n## **🔗 1. Attribution: Connecting Conversions to Campaigns**\nAttribution is the process of determining which campaigns are responsible for converting customers. Some channels, like Facebook or AdWords, can directly claim conversions. However, there are various attribution models to consider, including:\n  * First touch\n  * Last touch\n  * Multi-touch\n  * Time decay\n  * Position-based\n\n\nAttribution systems are not without their issues, with two main challenges:\n  * **Lag** : The time it takes to measure the performance of ads and attribute conversions accurately\n  * **Attribution Window** : The trade-off between using a short versus a long window to attribute conversions\n\n\nFor example, DoorDash used a several-day last-touch attribution system. The problem they faced was the need to wait for several days to measure the performance of their ads, which proved too lengthy given the rapid changes in their market.\n## **🔮 2. Performance Estimation: Predicting Campaign Success**\nPerformance estimation involves creating a model that can predict the success of a marketing campaign based on its budget allocation. Here, success can be defined in terms of various Key Performance Indicators (KPIs), such as:\n  * Leads\n  * Cost per Lead (CPL)\n  * Customer Lifetime Value (CLV)\n  * Customer Acquisition Cost (CAC)\n\n\nTraditionally, linear models have been used for performance estimation. However, they assume that marketing channels **don't exhibit diminishing returns** , which is often not the case. To obtain nontrivial solutions, linear models typically incorporate multiple constraints and are solved using Linear Programming (LP).\nIn reality, response curves in marketing mix modeling often display different shapes, such as:\n  * Linear (rare)\n  * Concave (common, indicating diminishing returns)\n  * Convex (rare)\n  * S-shaped (rare)\n\n\n![Image by author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/111lN_4-dOsUCjcAaTAx_9Q.png)\nImage by author\nThese shapes reflect the **diminishing returns** of marketing spending or the varying effectiveness of different channels at different budget levels. For example, investing more money into a channel might initially yield higher returns (convex), but after a certain point, each additional dollar may generate less and less incremental outcome (becoming concave), creating an S-shaped curve overall.\nTo capture the intrinsic nonlinearity of the marketing budget allocation problem, a more sophisticated approach is needed. This is where nonlinear programming, specifically conic optimization, comes into play.\n## **🔄 3. Optimization: Nonlinear Optimization with CVXPY**\nNonlinear programming, also known as nonlinear optimization, is a method used to solve optimization problems where the **objective function, constraints** , or both, are **nonlinear**. In simple terms, it's the process of finding the optimal solution (either maximizing or minimizing) for a system that's governed by a set of nonlinear equations.\nIn this example, we will model the returns for each marketing channel (response curve) using the natural logarithm as follows:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1lf8wotpF7ouqkw93ZcANdg.png)\nThe two previous steps of attribution and performance estimation approximate the values of αᵢ and βᵢ for every channel _i_. Let's take a simple example with three channels:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1N4AwN_qmar03JNVTHmZn0Q.png)\nThe noise observed in these values is typical in marketing budget allocation problems. Note that the alpha values are **negative** ; this can be interpreted as the initial cost of engaging with a new marketing channel.\nWe can plot the response curves of each marketing channel using matplotlib.\npython\n\n```\nimport matplotlib.pyplot as plt\nimport numpy as np\nnp.random.seed(0)\n\nTOTAL_BUDGET = 100_000\n\n# Alpha and beta constants\nalphas = np.array([-9453.72, -8312.84, -7371.33])\nbetas = np.array([8256.21, 7764.20, 7953.36])\n\n# Linearly spaced numbers\nx = np.linspace(1, TOTAL_BUDGET, TOTAL_BUDGET)\n\n# Plot the response curves\nfig = plt.figure(figsize=(10, 5), dpi=300)\nplt.plot(x, alphas[0] + betas[0] * np.log(x), color='red', label='Google Ads')\nplt.plot(x, alphas[1] + betas[1] * np.log(x), color='blue', label='Facebook Ads')\nplt.plot(x, alphas[2] + betas[2] * np.log(x), color='green', label='Twitter Ads')\nplt.xlabel('Budget ($)')\nplt.ylabel('Returns ($)') \nplt.legend()\nplt.show()\n```\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1Lgf5n8kGZiyPcRxbAdZC-A.png)\nHow to find the best values for each response curve? The easiest solution consists of a greedy algorithm that randomly samples values and evaluates the result. Our optimization problem can be described as follows:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1j-BlytwUNKojELFjxK5IJg.png)\nThe following function has a budget of 1,000 iterations to find the best allocation.\npython\n\n```\ndef greedy_optimization(TOTAL_BUDGET, alphas, betas, num_iterations=1_000):\n    # Initialize the budget allocation and the best objective value\n    google_budget = facebook_budget = twitter_budget = TOTAL_BUDGET / 3\n    obj = alphas[0] + betas[0] * np.log(google_budget) + alphas[1] + betas[1] * np.log(facebook_budget) + alphas[2] + betas[2] * np.log(twitter_budget)\n\n    for _ in range(num_iterations):\n        # Generate a new random allocation\n        random_allocation = np.random.dirichlet(np.ones(3)) * TOTAL_BUDGET\n        google_budget_new, facebook_budget_new, twitter_budget_new = random_allocation\n\n        # Calculate the new objective value\n        new_obj = alphas[0] + betas[0] * np.log(google_budget_new) + alphas[1] + betas[1] * np.log(facebook_budget_new) + alphas[2] + betas[2] * np.log(twitter_budget_new)\n\n        # If the new allocation improves the objective value, keep it\n        if new_obj > obj:\n            google_budget, facebook_budget, twitter_budget = google_budget_new, facebook_budget_new, twitter_budget_new\n            obj = new_obj\n\n    # Return the best allocation and the corresponding objective value\n    return (google_budget, facebook_budget, twitter_budget), objp\n```\n\nLet's run it and see the approximated solution it found:\npython\n\n```\n# Run the greedy optimization\n(best_google, best_facebook, best_twitter), obj = greedy_optimization(TOTAL_BUDGET, alphas, betas)\n\n# Print the result\nprint('='*59 + 'n' + ' '*24 + 'Solution' + ' '*24 + 'n' + '='*59)\nprint(f'Returns = ${round(obj):,}n')\nprint('Marketing allocation:')\nprint(f' - Google Ads   = ${round(best_google):,}')\nprint(f' - Facebook Ads = ${round(best_facebook):,}')\nprint(f' - Twitter Ads  = ${round(best_twitter):,}')\n```\n\nplaintext\n\n```\n===========================================================\n                        Solution                        \n===========================================================\nReturns = $224,534\n\nMarketing allocation:\n - Google Ads   = $35,476\n - Facebook Ads = $31,722\n - Twitter Ads  = $32,802\n```\n\nAfter running our calculations, we find that our total return is $224,533. You might wonder if we can improve it by tweaking our model more or running more iterations.\nThis kind of guarantee is exactly where nonlinear programming comes to the rescue: it can output the **best solution possible** , also called the optimal solution. On top of this overwhelming advantage, it is also faster to run.\nTo solve the marketing budget allocation problem using nonlinear programming, we'll use the [**CVXPY**](https://www.cvxpy.org/) library, which supports conic optimization thanks to specialized solvers like [ECOS](https://github.com/embotech/ecos), [MOSEK ](https://www.mosek.com/)(interior point method), and [SCS](https://github.com/cvxgrp/scs) (first-order method). In this example, we'll use the open-source ECOS solver to find the optimal solution.\nLet's set up the optimization problem:\n  * Our decision **variables** are the (positive) budgets for each channel\n  * Our **constraint** is that the sum of all budgets must not exceed the total budget\n  * Our **objective** is to maximize the total return, which is the sum of the returns for each channel\n\n\npython\n\n```\nimport cvxpy as cp\n\n# Variables\ngoogle   = cp.Variable(pos=True)\nfacebook = cp.Variable(pos=True)\ntwitter  = cp.Variable(pos=True)\n\n# Constraint\nconstraint = [google + facebook + twitter <= TOTAL_BUDGET]\n\n# Objective\nobj = cp.Maximize(alphas[0] + betas[0] * cp.log(google)\n                + alphas[1] + betas[1] * cp.log(facebook)\n                + alphas[2] + betas[2] * cp.log(twitter))\n```\n\nFinally, we call the ECOS solver to find the optimal budget allocations and display the results.\npython\n\n```\n# Solve\nprob = cp.Problem(obj, constraint)\nprob.solve(solver='ECOS', verbose=False)\n\n# Print solution\nprint('='*59 + 'n' + ' '*24 + 'Solution' + ' '*24 + 'n' + '='*59)\nprint(f'Status = {prob.status}')\nprint(f'Returns = ${round(prob.value):,}n')\nprint('Marketing allocation:')\nprint(f' - Google Ads   = ${round(google.value):,}')\nprint(f' - Facebook Ads = ${round(facebook.value):,}')\nprint(f' - Twitter Ads  = ${round(twitter.value):,}')\n```\n\nplaintext\n\n```\n===========================================================\n                        Solution                        \n===========================================================\nStatus = optimal\nReturns = $224,540\n\nMarketing allocation:\n - Google Ads   = $34,439\n - Facebook Ads = $32,386\n - Twitter Ads  = $33,175\n```\n\nThe optimal allocation found by the solver is $34,439 for Google Ads, $32,386 for Facebook Ads, and $33,175 for YouTube, for a total return of $224,540! This is **$7 higher than what the greedy algorithm returned** ($224,533).\nKeep in mind that this allocation maximizes the returns based on our response curves: correctly modeling these curves is crucial for optimizing the budget effectively.\nLet's visualize this optimal allocation on top of the previous response curves.\npython\n\n```\n# Plot the functions and the results\nfig = plt.figure(figsize=(10, 5), dpi=300)\n\nplt.plot(x, alphas[0] + betas[0] * np.log(x), color='red', label='Google Ads')\nplt.plot(x, alphas[1] + betas[1] * np.log(x), color='blue', label='Facebook Ads')\nplt.plot(x, alphas[2] + betas[2] * np.log(x), color='green', label='Twitter Ads')\n\n# Plot optimal points\nplt.scatter([google.value, facebook.value, twitter.value],\n            [alphas[0] + betas[0] * np.log(google.value),\n             alphas[1] + betas[1] * np.log(facebook.value),\n             alphas[2] + betas[2] * np.log(twitter.value)],\n            marker=\"+\", color='black', zorder=10)\n\nplt.xlabel('Budget ($)')\nplt.ylabel('Returns ($)') \nplt.legend()\nplt.show()\n```\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/10j-IvFi2z5ANnEL8q1_Gag.png)\nBut is it **really optimal**? We can do a quick sanity check by running the greedy algorithm for different numbers of iterations. This will show us the difference between these two approaches.\nLet's run it for 20 different numbers of iterations between 1 and 1,000,000.\npython\n\n```\n# List to store the best objective value for each number of iterations\nbest_obj_list = []\n\n# Range of number of iterations to test\nnum_iterations_range = np.logspace(0, 6, 20).astype(int)\n\n# Run the greedy algorithm for each number of iterations and store the best objective value\nfor num_iterations in num_iterations_range:\n    _, best_obj = greedy_optimization(TOTAL_BUDGET, alphas, betas, num_iterations)\n    best_obj_list.append(best_obj)\n```\n\nWe can now plot the resulting list using matplotlib and compare it to the optimal solution:\npython\n\n```\n# Plot the results\nplt.figure(figsize=(10, 5), dpi=300)\nplt.ticklabel_format(useOffset=False)\nplt.plot(num_iterations_range, best_obj_list, label='Greedy algorithm')\nplt.axhline(y=prob.value, color='r', linestyle='--', label='Optimal solution (CVXPY)')\nplt.xlabel('Number of iterations')\nplt.xticks(num_iterations_range)\nplt.xscale(\"log\")\nplt.ylabel('Best returns ($)')\nplt.title('Best returns found by the greedy algorithm for different numbers of iterations')\nplt.legend()\nplt.show()\n```\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1yYPAFvAsDfQ6xuuUl7uEvw.png)\nWe observe that the greedy algorithm performs relatively well when given a large number of iterations. However, despite one million attempts, it falls just short of finding the optimal allocation, which yields a return of $224,540.1500. The best non-rounded value it could reach is $224,540.1489.\nTo add to this, there's a significant difference in terms of **computational speed** between the two approaches. The nonlinear programming model identified the optimal solution in a swift 22.3 milliseconds. In stark contrast, the greedy algorithm took a considerable 30 seconds to run its 1 million iterations and find a nearly optimal solution.\nThis disparity becomes even more crucial when we extend our problem to **numerous marketing channels**. Nonlinear programming with CVXPY maintains its speed and precision, making it a highly efficient tool for complex, high-dimensional marketing budget allocation problems.\n## **Conclusion**\nNonlinear programming offers a powerful approach to tackling the marketing budget allocation problem. By modeling the diminishing returns of each marketing channel with **nonlinear functions** and leveraging the CVXPY library, we can find the optimal allocation of resources that maximizes sales.\nAs the marketing landscape evolves and the number of channels increases, optimization techniques like nonlinear programming can help businesses make better, data-driven decisions about their marketing investments. While this article provides a starting point, there are many more advanced techniques and models to explore. Keep learning and experimenting to find the best approach for your business.\nIf you're interested to know more about it, feel free to follow me on Twitter [@maximelabonne](https://twitter.com/maximelabonne). Happy optimizing!\n## **References**\nIf you want to learn more about marketing budget allocation, I recommend the following resources:\n  * Park et al., [A Nonlinear Optimization Model of Advertising Budget Allocation across Multiple Digital Media Channels](https://scholarspace.manoa.hawaii.edu/server/api/core/bitstreams/ea6310e7-8ef8-4335-9625-b82b11042797/content) (2022): an excellent approach based on diminishing returns, which inspired this article.\n  * Zhao et al., [A Unified Framework for Marketing Budget Allocation](https://arxiv.org/pdf/1902.01128.pdf) (2019): fascinating architecture currently in production at Alibaba, based on a logit response curve.\n  * Katsov, [Cross-channel marketing spend optimization using deep learning](https://blog.griddynamics.com/cross-channel-marketing-spend-optimization-deep-learning/) (2019): blog post about an intriguing LSTM-based approach, without convex optimization.\n\n\n## Related articles\n> [**Introduction to Linear Programming in Python**](https://towardsdatascience.com/introduction-to-linear-programming-in-python-9261e7eb44b)\n> [**Integer vs. Linear Programming in Python**](https://towardsdatascience.com/integer-programming-vs-linear-programming-in-python-f1be5bb4e60e)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657499317_sxy3ci.png)\nWritten By\n## [Maxime Labonne](https://towardsdatascience.com/author/mlabonne/)\n[See all from Maxime Labonne](https://towardsdatascience.com/author/mlabonne/)\n[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Cvxpy](https://towardsdatascience.com/tag/cvxpy/)[Hands On Tutorials](https://towardsdatascience.com/tag/hands-on-tutorials/)[Linear Programming](https://towardsdatascience.com/tag/linear-programming/)[Nonlinear Programming](https://towardsdatascience.com/tag/nonlinear-programming/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F&title=The%20Art%20of%20Spending%3A%20Optimizing%20Your%20Marketing%20Budget%20with%20Nonlinear%20Optimization)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F&title=The%20Art%20of%20Spending%3A%20Optimizing%20Your%20Marketing%20Budget%20with%20Nonlinear%20Optimization)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F&text=The%20Art%20of%20Spending%3A%20Optimizing%20Your%20Marketing%20Budget%20with%20Nonlinear%20Optimization)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2026/02/image-175.jpg)](https://towardsdatascience.com/generalizable-marl-lp-approach-for-scheduling-in-logistics/)\n## [A Generalizable MARL-LP Approach for Scheduling in Logistics](https://towardsdatascience.com/generalizable-marl-lp-approach-for-scheduling-in-logistics/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nPart 1. Hybrid Solution for Dynamic Vehicle Routing — Context and Architecture\n[Alexander Levin](https://towardsdatascience.com/author/alexander.levin/)\nFebruary 26, 202614 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/06/0XVkeBEzS6xFV0Kb_-scaled.jpg)](https://towardsdatascience.com/the-starter-guide-for-transitioning-your-python-projects-to-r-8de4122b04ad/)\n## [The Starter Guide For Transitioning Your Python Projects To R](https://towardsdatascience.com/the-starter-guide-for-transitioning-your-python-projects-to-r-8de4122b04ad/)\n[Data Visualization](https://towardsdatascience.com/category/data-science/data-visualization/)\nExploring Electric vehicle trends in R\n[Stephanie Lo](https://towardsdatascience.com/author/stephanie_lo/)\nJune 2, 202311 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0gc4kJc_-vwWAkMzv-scaled.jpg)](https://towardsdatascience.com/a-bayesian-take-on-model-regularization-9356116b6457/)\n## [A Bayesian Take On Model Regularization](https://towardsdatascience.com/a-bayesian-take-on-model-regularization-9356116b6457/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nIn this article, we explore how we can, and do, regularize and control the complexity of the models we learn through Bayesian prior...\n[Ryan S](https://towardsdatascience.com/author/rmsander/)\nFebruary 1, 20219 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/08/1X4I4_PO9l14apt0h3Nbw2A.jpeg)](https://towardsdatascience.com/graph-convolutional-networks-introduction-to-gnns-24b3f60d6c95/)\n## [Graph Convolutional Networks: Introduction to GNNs](https://towardsdatascience.com/graph-convolutional-networks-introduction-to-gnns-24b3f60d6c95/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA step-by-step guide using PyTorch Geometric\n[Maxime Labonne](https://towardsdatascience.com/author/mlabonne/)\nAugust 14, 202317 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/1Jvf7A1CznBjpuxAQ55IstQ.png)](https://towardsdatascience.com/enterprise-ml-why-building-and-training-a-real-world-model-is-hard-59d09a430fae/)\n## [Enterprise ML - Why building and training a \"real-world\" model is hard](https://towardsdatascience.com/enterprise-ml-why-building-and-training-a-real-world-model-is-hard-59d09a430fae/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nA Gentle Guide to the lifecycle of a Machine Learning project in the Enterprise, the roles involved and the challenges of building models...\n[Ketan Doshi](https://towardsdatascience.com/author/ketanhdoshi/)\nJune 17, 20219 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/11/19tBdHG_11ObTZSc7egW6EA-scaled.jpeg)](https://towardsdatascience.com/efficient-model-fine-tuning-with-bottleneck-adapter-5162fcec3909/)\n## [Efficient Model Fine-Tuning with Bottleneck Adapter](https://towardsdatascience.com/efficient-model-fine-tuning-with-bottleneck-adapter-5162fcec3909/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nHow to fine-tune Transformer-based models with bottleneck adapters\n[Ruben Winastwan](https://towardsdatascience.com/author/marcellusruben/)\nNovember 22, 202314 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/04/0DSTQkcyX56nl4qYu.png)](https://towardsdatascience.com/fine-tune-llama-3-with-orpo-56cfab2f9ada/)\n## [Fine-tune Llama 3 with ORPO](https://towardsdatascience.com/fine-tune-llama-3-with-orpo-56cfab2f9ada/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA cheaper and faster unified fine-tuning technique\n[Maxime Labonne](https://towardsdatascience.com/author/mlabonne/)\nApril 19, 20247 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/0uGIuF8aUmOAkKxQ--scaled.jpg)](https://towardsdatascience.com/caret-vs-tidymodels-how-to-use-both-packages-together-ee3f85b381c/)\n## [Caret vs Tidymodels: How to Use Both Packages Together?](https://towardsdatascience.com/caret-vs-tidymodels-how-to-use-both-packages-together-ee3f85b381c/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAn example of using both popular machine learning packages in R to predict bike sharing demand\n[Yu-En Hsu](https://towardsdatascience.com/author/yuenhsu/)\nJanuary 8, 202110 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/1s38XvmAhBX5daL4Zmkw3oA.jpeg)](https://towardsdatascience.com/understanding-abstractions-in-neural-networks-22cc2cd54597/)\n## [Understanding Abstractions in Neural Networks](https://towardsdatascience.com/understanding-abstractions-in-neural-networks-22cc2cd54597/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nHow thinking machines implement one of the most important functions of cognition.\n[林育任 (Yu-Jen Lin)](https://towardsdatascience.com/author/yujen-lin/)\nMay 14, 202413 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "The Art of Spending: Optimizing Your Marketing Budget with Nonlinear Optimization | Towards Data Science",
    "description": "Introduction to CVXPY to maximize marketing ROI",
    "keywords": null,
    "author": "Maxime Labonne",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "The Art of Spending: Optimizing Your Marketing Budget with Nonlinear Optimization",
    "og:description": "Introduction to CVXPY to maximize marketing ROI",
    "og:url": "https://towardsdatascience.com/the-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1cQ5wZBXJLBvCOU_Vu1b-_A.jpeg",
    "og:image:width": "1820",
    "og:image:height": "1024",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Maxime Labonne",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "9 min read",
    "article:published_time": "2023-05-22T21:11:41.000Z",
    "article:modified_time": "2023-05-22T21:11:41.000Z",
    "article:author": "https://towardsdatascience.com/author/mlabonne/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_000.txt",
      "chars": 681
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_001.txt",
      "chars": 1208
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_002.txt",
      "chars": 442
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_003.txt",
      "chars": 297
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_004.txt",
      "chars": 389
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_005.txt",
      "chars": 438
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_006.txt",
      "chars": 314
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_007.txt",
      "chars": 711
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_008.txt",
      "chars": 443
    },
    {
      "language": "txt",
      "file": "attachments/0eb9877364ad/code/block_009.txt",
      "chars": 486
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/1cQ5wZBXJLBvCOU_Vu1b-_A.jpeg",
      "alt": "Image by author",
      "local_path": "attachments/0eb9877364ad/images/000.jpeg",
      "bytes": 69813,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/111lN_4-dOsUCjcAaTAx_9Q.png",
      "alt": "Image by author",
      "local_path": "attachments/0eb9877364ad/images/001.png",
      "bytes": 27443,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2026/02/image-175.jpg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/002.jpg",
      "bytes": 206759,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/06/0XVkeBEzS6xFV0Kb_-scaled.jpg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/003.jpg",
      "bytes": 250162,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0gc4kJc_-vwWAkMzv-scaled.jpg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/004.jpg",
      "bytes": 306082,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/08/1X4I4_PO9l14apt0h3Nbw2A.jpeg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/005.jpeg",
      "bytes": 188966,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/1Jvf7A1CznBjpuxAQ55IstQ.png",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/006.png",
      "bytes": 141152,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/11/19tBdHG_11ObTZSc7egW6EA-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/007.jpeg",
      "bytes": 395526,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/04/0DSTQkcyX56nl4qYu.png",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/008.png",
      "bytes": 1721815,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/0uGIuF8aUmOAkKxQ--scaled.jpg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/009.jpg",
      "bytes": 571851,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/1s38XvmAhBX5daL4Zmkw3oA.jpeg",
      "alt": "",
      "local_path": "attachments/0eb9877364ad/images/010.jpeg",
      "bytes": 141486,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [
    {
      "src": "https://www.youtube.com/c/TowardsDataScience",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/mlabonne/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/introduction-to-linear-programming-in-python-9261e7eb44b"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/integer-programming-vs-linear-programming-in-python-f1be5bb4e60e"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/cvxpy/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/hands-on-tutorials/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/linear-programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/nonlinear-programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/generalizable-marl-lp-approach-for-scheduling-in-logistics/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/alexander.levin/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/the-starter-guide-for-transitioning-your-python-projects-to-r-8de4122b04ad/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/data-visualization/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/stephanie_lo/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/a-bayesian-take-on-model-regularization-9356116b6457/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://github.com/mlabonne/linear-programming-course/blob/main/4_Maximize_Your_Marketing_ROI_with_Nonlinear_Optimization.ipynb"
    },
    {
      "type": "external",
      "href": "https://colab.research.google.com/drive/1V7z8giemuTk92s_JMxIyr1Clr2TwY7xl?usp=sharing"
    },
    {
      "type": "external",
      "href": "https://www.cvxpy.org/"
    },
    {
      "type": "external",
      "href": "https://github.com/embotech/ecos"
    },
    {
      "type": "external",
      "href": "https://www.mosek.com/"
    },
    {
      "type": "external",
      "href": "https://github.com/cvxgrp/scs"
    },
    {
      "type": "external",
      "href": "https://twitter.com/maximelabonne"
    },
    {
      "type": "external",
      "href": "https://scholarspace.manoa.hawaii.edu/server/api/core/bitstreams/ea6310e7-8ef8-4335-9625-b82b11042797/content"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/1902.01128.pdf"
    },
    {
      "type": "external",
      "href": "https://blog.griddynamics.com/cross-channel-marketing-spend-optimization-deep-learning/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=The+Art+of+Spending%3A+Optimizing+Your+Marketing+Budget+with+Nonlinear+Optimization&u=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=The+Art+of+Spending%3A+Optimizing+Your+Marketing+Budget+with+Nonlinear+Optimization&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=The+Art+of+Spending%3A+Optimizing+Your+Marketing+Budget+with+Nonlinear+Optimization&url=https%3A%2F%2Ftowardsdatascience.com%2Fthe-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    },
    {
      "type": "external",
      "href": "https://bsky.app/profile/towardsdatascience.com"
    },
    {
      "type": "external",
      "href": "https://thenewstack.io"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:48Z",
  "source_url": "https://towardsdatascience.com/the-art-of-spending-optimizing-your-marketing-budget-with-nonlinear-optimization-6c8a39afb3c2/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}