(h, X)
| 100 | # |
| 101 | # built-in weighted multi-objective optimization |
| 102 | def highs_weighted(h, X): |
| 103 | print('## Built-in Weighted:\n') |
| 104 | h.setOptionValue('blend_multi_objectives', True) # use weighted |
| 105 | |
| 106 | for k in range(OBJECTIVES): |
| 107 | obj = HighsLinearObjective() |
| 108 | obj.coefficients = profit[k,:].tolist() |
| 109 | obj.weight = -1.0/(k+1) |
| 110 | |
| 111 | h.addLinearObjective(obj) |
| 112 | |
| 113 | h.solve() |
| 114 | print(f' SOL: [{"".join(map(lambda x: "{:1.0f}".format(x), abs(h.vals(X))))}]') |
| 115 | print(f' OBJ: {pretty_print(np.dot(profit, h.vals(X)))}\n') |
| 116 | |
| 117 | print(f' Number of objectives: {h.getNumLinearObjectives()}') |
| 118 | for k in range(h.getNumLinearObjectives()): |
| 119 | obj = h.getLinearObjective(k) |
| 120 | print(f' Obj {k+1}: weight={obj.weight}, priority={obj.priority}, abs_tol={obj.abs_tolerance}, rel_tol={obj.rel_tolerance}') |
| 121 | print('\n') |
| 122 | |
| 123 | h.clearLinearObjectives() |
| 124 | |
| 125 | |
| 126 | if __name__ == "__main__": |
no test coverage detected