java,smt,integer-programming,sat-solvers

GLPK, open-source package for LP and (mixed) ILP has Java binding. Another open-source solvers are lp_solve (Java API) and SCIP. There are also commercial solvers - CPLEX, GUROBI and Mosek, all with Java interface. Btw. for my homeworks, I found Python and PuLP a bit easier to work with :)...

linear-programming,integer-programming

Rewriting loannis's answer in a linear form by expanding out multiplication of binary variables with a continuous variable: Tc <= M*Y Tc <= A Tc >= A - M*(1-Y) Tc >= 0 Tc <= X Td <= M*Y Td <= B Td >= B - M*(1-Y) Td >= 0 X...

python,linear-programming,gurobi,integer-programming

In the gurobi python API, you can simply set the vtype attribute on the variable. It is easy if you save a reference to the variable In your case, if you create a varaible x = m.addVar(lb=0, ub=1, vtype=GRB.CONTINUOUS) You can set it's attribe x.vtype = GRB.BINARY You can see...

optimization,mathematical-optimization,linear-programming,scientific-computing,integer-programming

Edit: Setting Variable2 equal to min or max of Variable1 and Parameter. min(Parameter,Variable1): If you are sure that Variable2 "wants" to be small in the objective function, then you just need to require Variable2 to be less than or equal to both Parameter and Variable1: Variable2 <= Variable1 Variable2 <=...

mathematical-optimization,linear-programming,integer-programming,quadratic-programming

Models in this form are actually called bilinear optimization problems. The typical approach to linearizing bilinear terms is through something called the McCormick envelope. Consider variables x and y, where you want x*y in the objective of your maximization problem. If we assume x and y are bounded by xL...

real-time,knapsack-problem,integer-programming

This is the standard knapsack problem which can be solved efficiently using dynamic programming. This has been discussed nicely in the knapsack wiki (and also in mutiple stack overflow posts e.g. here DP algo for knapsack and here recursive knapsack) The c++ implementation measures ~20us on my core i7 @3Ghz...

optimization,mathematical-optimization,linear-programming,scientific-computing,integer-programming

First create a binary variable that equals 1 if Variable1 > 0 and 0 if Variable1 < 0: Variable1 <= UB * BinaryVar LB * (1 - BinaryVar) <= Variable1 (If Variable1 > 0, then BinaryVar must equal 1. If Variable1 < 0, then BinaryVar must equal 0. Note that...

python,mathematical-optimization,linear-programming,gurobi,integer-programming

To obtain the best feasible answer so far, you should first verify that there is a feasible solution by checking the Status attribute on your model object, then querying the X attribute on your variable objects. If you have named your variables (with the name parameter on e neat way...