[Cbc] wrapper to create matrix via variables/constraints (not rows/columns)

Mike Steglich mike.steglich at stegger.net
Fri Jan 29 08:48:45 EST 2016


Hello Felix,

There is also CMPL (Coin Mathematical Programming Language) -> http://www.coin-or.org/projects/Cmpl.xml <http://www.coin-or.org/projects/Cmpl.xml> which could be interesting for you. 

E.g. the diet problem looks in CMPL like follows:

parameters:
	NUTR := set("A","B1", "B2", "C");
	FOOD := set("BEEF", "CHK", "FISH", "HAM", "MCH", "MTL", "SPG", "TUR");
	
	#cost per package
	costs[FOOD] := ( 3.19, 2.59, 2.29, 2.89, 1.89, 1.99, 1.99, 2.49 );

	#provision of the daily requirements for vitamins in percentages 
	vitamin[NUTR, FOOD] := ( (60, 8, 8, 40, 15, 70, 25, 60) ,
				 	  (20, 0, 10, 40, 35, 30, 50, 20) ,
				 	  (10, 20, 15, 35, 15, 15, 25, 15),
				 	  (15, 20, 10, 10, 15, 15, 15, 10)
		     	       	);

	#weekly vitamin requirements
	vitMin[NUTR]:= (700,700,700,700);
variables:
	x[FOOD]: integer[2..10];

objectives:
	cost: costs[]T * x[]->min;

constraints:
	# capacity restriction 
	vitamin[,] * x[] >= vitMin[];

CMPL executes CBC (and other solvers) directly.


Cheers,

Mike


> Am 28.01.2016 um 19:50 schrieb Felix Brandt <brandt at fzi.de>:
> 
> Dear all,
> 
> I'm looking for a way to describe the constraints of a CBC model in a more natural way than by using row/column indices. Gurobi has a simple API where vars and constraints can be specified directly, looking like the following:
> 
> Model model;
> Variable var1 = model.addVar();
> Variable var2 = model.addVar();
> model.addConstr (2 * var1 + var2 <= 5);
> 
> I wonder if something similar exists for CBC (maybe in other CoinOR projects)? I searched the web and this ML but found nothing so far. Maybe I'm just using the wrong keywords.
> Technically, this should not be that hard as the objects can just be wrappers for the matrix indices and the matrix can be rendered after all constraints have been added. So, before I reinvent the wheel I thought I better ask here ;) Thanks!
> 
> Cheers,
> Felix
> 
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160129/85a0972a/attachment.html>


More information about the Cbc mailing list