[Python] Root mean square linearisation for linear programming

Discussão em 'Python' iniciado por Stack, Maio 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to linearise the function root mean square to use it in a linear optimisation or Mixed integer linear optimisation. Any idea how I could do this? For instance with the example below, if I wanted to maximize P*100, the model would give P=10, Q = 0 and S=10.

    Many thanks

    import numpy as np
    import pulp

    S = np.sqrt(P**2 + Q**2)

    model = pulp.LpProblem("Linearise RMS", pulp.LpMaximize)

    P = pulp.LpVariable("P", lowBound=-10, upBound=10 ,cat="Continuous")
    Q = pulp.LpVariable("Q", lowBound=-10, upBound=10 ,cat="Continuous")
    S = pulp.LpVariable("S", lowBound= 0, upBound=10 ,cat="Continuous")

    objective_function = P*100

    model.setObjective(objective_function)
    cbc_solver = PULP_CBC_CMD(options=['ratioGap=0.02'])
    result = model.solve(solver=cbc_solver)

    Continue reading...

Compartilhe esta Página