# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# <table width = "100%">
#   <tr style="background-color:white;">
#     <!-- QWorld Logo -->
#     <td style="text-align:left;width:200px;"> 
#         <a href="https://qworld.net/" target="_blank"><img src="../images/QWorld.png"> </a></td>
#     <td style="text-align:right;vertical-align:bottom;font-size:16px;"> 
#         Prepared by <a href="https://gitlab.com/sabahuddin.ahmad" target="_blank"> <NAME> </a></td>
#     </tr> 
#  </table>
#  
# <hr>

# ## <font color="blue"> Solutions for </font> QUBO Formulation with Penalty Method

# <a id="task1"></a>
# ### Task 1
#
# Consider a constrained problem of the form:
# $$\min y = f(x)$$
#
# which is subjected to the constraint $x_1+ x_2 \leq 1$ ($x_1$ & $x_2$ are binary variables). What will be the equivalent penalty for this problem? What will be the form of the related unconstrained problem?

# <h3> Solution </h3>

# From the table, the equivalent quadratic penalty is:
#
# $$Px_1x_2$$
#
# For a sufficiently large value of P, the form of the unconstrained problem is:
#
# $$\min y = f(x)+Px_1x_2$$.
#
# **Comments:** The optimizer will avoid solutions having both $x_1$ & $x_2$ equal to 1. If this happens, a large penalty is added to the objective function corresponding to infeasible solutions. 

# <a id="task2"></a>
# ### Task 2
#
# Consider a constrained problem of the form:
# $$\min y = f(x)$$
#
# which is subjected to the constraint $x_1+ x_2 = 1$ ($x_1$ & $x_2$ are binary variables). What will be the equivalent penalty for this problem? What will be the form of the related unconstrained problem?
#

# <h3> Solution </h3>

# From the table, the equivalent quadratic penalty is:
#
# $$P(1-x_1-x_2+2x_1x_2)$$
#
# For a sufficiently large value of P, the form of the unconstrained problem is:
#
# $$\min y = f(x)+P(1-x_1-x_2+2x_1x_2)$$.

StarcoderdataJupyterScriptsDedupFiltered