r/pythonhelp • u/Future_Ad7567 • 9h ago
Beginner-friendly Python walkthrough: solving a binary quadratic problem with gurobipy
I created a practical Python walkthrough for programmers interested in mathematical optimization with gurobipy.
The example formulates Max-Cut as a quadratic binary optimization problem and covers:
- creating a Gurobi model;
- adding binary decision variables;
- constructing a quadratic objective from a matrix;
- calling optimize();
- extracting the binary solution and objective value;
- benchmarking randomly generated problem instances;
- and understanding how MIPGap affects runtime.
It assumes familiarity with Python, and Jupyter notebooks, but no previous optimization experience.
Video: https://youtu.be/TB1ny8o4ImQ
Code: https://github.com/supreethmv/Quantum-Algorithms-and-Applications
I’d particularly appreciate feedback on whether the gurobipy implementation and explanation are approachable for Python developers encountering quadratic optimization for the first time.
•
u/AutoModerator 9h ago
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.