To optimize their profits, do miners use software like Gurobi or other LP-solvers to solve the knapsack problem and select the most profitable transactions?
I'm only talking about honest miners who only want to maximize their profits.
Miners always want to maximize their income from mining activities and want to get profit from mining, not a draw or loss from mining. If they can not get profit, they will capitulate.
https://www.bitcoinmagazinepro.com/charts/hash-ribbons/Miners as solo miners can be not too technical, unprofessional but mining pools are professional and they will have tools to automate their works. Nowadays, there is little space for solo miners and most Bitcoin miners participate in Bitcoin mining pools, with automatic tools to filter and pick transactions to maximize their income from transaction fees.
Bitcoin mining pools have their own Bitcoin full nodes with customized settings like a setting on minimum transaction fee rate.
https://learnmeabitcoin.com/technical/mining/memory-pool/#settings