Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abhijeet-talaulikar/62b3f567819370ba22f4c1d20a93a0a7 to your computer and use it in GitHub Desktop.
Save abhijeet-talaulikar/62b3f567819370ba22f4c1d20a93a0a7 to your computer and use it in GitHub Desktop.
# 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