Created
June 24, 2023 20:46
-
-
Save abhijeet-talaulikar/62b3f567819370ba22f4c1d20a93a0a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Value of the objective function (ROI) | |
print(f"The Optimal Objective Value {opt_model.objVal}") | |
# Values of decision variables (Funds allocated to each channel) | |
opt_df = pd.DataFrame.from_dict(x_vars, orient="index", columns=["Variable Object"]) | |
opt_df.reset_index(inplace=True) | |
opt_df.rename(columns={"index": "Media"}, inplace=True) | |
opt_df["Budget Allocated"] = opt_df["Variable Object"].apply(lambda item: item.X) | |
plt.bar(opt_df["Media"], opt_df["Budget Allocated"]) | |
plt.xlabel("Media") | |
plt.ylabel("Budget Allocated") | |
plt.title("Optimized Budget Allocation") | |
plt.xticks(rotation='vertical') | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment