Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a formulation of your problem that ends up a mixed integer and non linear programming problem:</p> <p>For all building type <code>i</code> let's define:</p> <ul> <li><code>Pi</code> : price of building type <code>i</code></li> <li><code>Ci</code> : Price increment of building type <code>i</code></li> <li><code>Mi</code> : income for building type <code>i</code></li> <li><code>B</code> : Budget</li> <li><code>Ni</code> : Number of buildings of type <code>i</code> purchased.</li> </ul> <p>Purchasing Ni building of type i equals:</p> <pre><code>Sum for j=1 to Ni Pi + (j - 1) × Ci = Ni (Pi + ( Ni - 1) / 2 × Ci) </code></pre> <p>Mixed integer non linear programming formulation:</p> <pre><code>Maximise Sum for i Ni × Mi Subject to : sum for i Ni (Pi + (Ni - 1) / 2 ×Ci) &lt;= B </code></pre> <p>Note that Pi, Ci, Mi and B are constants. Decision variables are Ni</p> <p>An other solution is to purchase a building at a time selecting the one with the maximum income per invested money as per the following ratio:</p> <pre><code>Mi / (Ni (Pi + ( Ni - 1) / 2 × Ci)) </code></pre> <p>At each step you calculate the building with the maximum ratio, purchase a building, deduct the price of the budget and repeat until the budget is exhausted. I do not have a proof that you will get an optimum my following this algorithm.</p> <p>Third solution pseudocode (brute force):</p> <pre><code>(income, index_list) function maximize_income(i, b) if i &gt; last_building_type return 0, [] endif max_income = 0 max_income_index = 0 while b &gt;= P(i) - (j-1) * C(i) b = b - P(i) - (j-1) * C(i) (income, index_list) = maximize_income(i+1, b) income = income + j * M(i) if income &gt; maximum_income maximum_income = income maximum_income_index = j endif endwhile add maximum_income_index to index_list return maximum_income, index_list end function </code></pre> <p>index_list is an array containing the number of each type of building </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload