RunKit + npm: constrained

node v8.12.0
version: 2.0.3
endpointsharetweet
var Constrained = require("constrained"); // Instantiation of the system var mySystem = new Constrained.System(); //Maximum draw we want to set at 14kW //c = Ewan's solar //x = Matthew's Breaker //y = Jukka's Breaker //i = Matthew's Charger //j = Jukka's Charger var myObject1 = { i: 0, j:0 }; var myObject2 = { x: 8, y: 10 , c: 14 }; // Instantiation of the variables and the constant mySystem.addVariable('i', myObject1, 'i'); // variable named x mySystem.addVariable('j', myObject1, 'j'); // variable named y mySystem.addConstant('x', myObject2, 'x'); mySystem.addConstant('y', myObject2, 'y'); mySystem.addConstant('c', myObject2, 'c'); // Displaying the result mySystem.log(); // Definition of the system mySystem.addConstraint('i + j <= c'); mySystem.addConstraint('i <= x'); mySystem.addConstraint('j <= y'); mySystem.addConstraint('i <= 10'); mySystem.addConstraint('i >= 2.5'); mySystem.addConstraint('j <= 7.7'); mySystem.addConstraint('j >= 1.8'); // Displaying the result mySystem.log(); //mySystem.maximize('i + j'); // Solving the system to obtain a feasible solution mySystem.resolve(); // Displaying the result mySystem.log(); // Making sure that objects have been updated //console.log('(i, j) = (', myObject1.i, ',', myObject1.j,')');
Created from: https://npm.runkit.com/constrained
Loading…

no comments

    sign in to comment