MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / highs_weighted

Function highs_weighted

examples/multi_objective.py:102–123  ·  view source on GitHub ↗
(h, X)

Source from the content-addressed store, hash-verified

100#
101# built-in weighted multi-objective optimization
102def 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
126if __name__ == "__main__":

Callers 1

multi_objective.pyFile · 0.85

Calls 12

rangeFunction · 0.85
mapFunction · 0.85
pretty_printFunction · 0.85
joinMethod · 0.80
valsMethod · 0.80
dotMethod · 0.80
setOptionValueMethod · 0.45
addLinearObjectiveMethod · 0.45
solveMethod · 0.45
clearLinearObjectivesMethod · 0.45

Tested by

no test coverage detected