mixed-integer-programming

How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?

随声附和 提交于 2021-02-10 14:27:43
问题 I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error: DOcplexException: Model.if_then(), nbBus40 >= 3.0 is not discrete This is happening because I have declared nbbus40 variable to be continuous , as shown in the code below: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.continuous_var(name=

How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?

[亡魂溺海] 提交于 2021-02-10 14:27:01
问题 I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error: DOcplexException: Model.if_then(), nbBus40 >= 3.0 is not discrete This is happening because I have declared nbbus40 variable to be continuous , as shown in the code below: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.continuous_var(name=

Google OR-Tools (using SCIP solver) - How to access the intermediate solutions found by the solver?

只谈情不闲聊 提交于 2021-01-29 17:20:39
问题 I'm new to Google OR-Tools. Using Python, I implemented a MIP model with SCIP as a solver. The objective function is for minimization ( solver.Minimize(C) ) and I am accessing the final solution through solver.Objective().Value() . However, I also need to access the intermediate solutions that the solver finds, before reaching the final one, and their timestamp . (The final goal is to plot a graph with the solutions evolution through time). I tried to use a while loop: solutions_evolution = {

How to ask for second best solution to a MIP using JuMP

房东的猫 提交于 2020-06-14 04:06:54
问题 I have a Mixed Integer Programming problem. I can use JuMP to find the optimal solution. But how can I find the second best solution? Or the third-best etc. This potentially might be another equally optimal solution, or it might be a worse solution, or it might be :Infeasible -- there might be no most solutions. I know for a TSP-like problem, I can find additional solutions by progressively removing links that are on the optimal path (I.e setting the distances between some of the cities to be

Putting integer constraints in mystic

删除回忆录丶 提交于 2020-06-09 05:32:06
问题 I am new to mystic and working on an optimization problem.My mystic code looks like this: def find_loss(e,lmd,q,k): edge_pmf=find_final_dist(e,lmd,q) l_e=sum(edge_pmf[k+1:]) return l_e def objective(x): s=0 for i in range(len(x)): s+=find_loss(edge_enum[i],lamd,q,x[i]) return s added=lambda x: [i for i in x] cons=lambda x: my.constraints.impose_sum(total_cap,added(x)) @integers() def round(x): return x bounds=[(0,None)]*a if __name__=='_main_': result=diffev2(objective,x0=bounds,bounds=bounds

R optimisation buy sell

戏子无情 提交于 2020-06-01 05:55:19
问题 I need to find a solution to an optimisation problem. In my simplified example, I have a prediction of prices for the next year. I have inventory that can contain max 25 products. I can either sell or buy each month. I cannot buy more than 4 products or sell more than 8 products per month. I am looking for profit by buying for lower price than selling. Is there a package/function that can indicate when to buy and when to sell? The objective is to maximise the profit at the end of the period

R optimisation buy sell

社会主义新天地 提交于 2020-06-01 05:54:13
问题 I need to find a solution to an optimisation problem. In my simplified example, I have a prediction of prices for the next year. I have inventory that can contain max 25 products. I can either sell or buy each month. I cannot buy more than 4 products or sell more than 8 products per month. I am looking for profit by buying for lower price than selling. Is there a package/function that can indicate when to buy and when to sell? The objective is to maximise the profit at the end of the period

R optimisation max buy/sell dependent on stock level

风格不统一 提交于 2020-06-01 05:03:50
问题 I would like to find a solution to an optimisation problem. The aim is to maximise profit by buying for low price and selling for a higher one. There are constraints such as maximum stock level, and max buy/sell number of units. Moreover, sell and buy limits depend on the inventory levels. I have asked a similar question albeit without the last condition here R optimisation buy sell. Here is an example: price = c(12, 11, 12, 13, 16, 17, 18, 17, 18, 16, 17, 13) capacity = 25 max_units_buy_30 =

R optimisation max buy/sell dependent on stock level

﹥>﹥吖頭↗ 提交于 2020-06-01 05:03:19
问题 I would like to find a solution to an optimisation problem. The aim is to maximise profit by buying for low price and selling for a higher one. There are constraints such as maximum stock level, and max buy/sell number of units. Moreover, sell and buy limits depend on the inventory levels. I have asked a similar question albeit without the last condition here R optimisation buy sell. Here is an example: price = c(12, 11, 12, 13, 16, 17, 18, 17, 18, 16, 17, 13) capacity = 25 max_units_buy_30 =

Cplex Error: Adding trivial infeasible linear constraint

杀马特。学长 韩版系。学妹 提交于 2020-04-17 19:05:31
问题 I want to solve an integer programming model with cplex python. I have this model: a and h are matrixes with 0s and 1s. p is a set of numbers. here is a part of my cplex code for this model: p=[i for i in range (len(h))] x=mdl.binary_var_dict(p,name='x') #objective mdl.minimize(0) #constraints #1 mdl.add_constraints(mdl.sum(h[i][k]*x[i] for i in p)==4 for k in T) #2 mdl.add_constraints(mdl.sum(a[i][k]*x[i] for i in p)==4 for k in T) mdl.print_information() Solution = mdl.solve(log_output