ivordir / yalps Goto Github PK
View Code? Open in Web Editor NEWYet Another Linear Programming Solver. (A rewrite of javascript-lp-solver.) Aims to be decently fast.
License: MIT License
Yet Another Linear Programming Solver. (A rewrite of javascript-lp-solver.) Aims to be decently fast.
License: MIT License
When importing YALPS, I get the following issue:
There are types at '/.../node_modules/yalps/lib/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'yalps' library may need to update its package.json or typings.
The model:
{
direction: 'maximize',
objective: 'p1',
constraints: {
p1: { min: 0 },
p2: { min: 2704 },
p3: { min: 4221 },
p4: { min: 0 },
cost: { max: 11004 }
},
variables: {
s1: { cost: 10, p1: 19, p2: 6, p3: 6 },
s2: { cost: 10, p2: 24, p3: 6 },
s3: { cost: 10, p2: 6, p3: 26 },
s4: { cost: 10, p1: 31 },
s5: { cost: 15, p1: 31, p2: 8, p3: 8 },
s6: { cost: 15, p2: 36, p3: 8 },
s7: { cost: 15, p2: 8, p3: 39 },
s8: { cost: 15, p1: 46 },
s9: { cost: 20, p1: 46, p2: 8, p3: 8 },
s10: { cost: 20, p1: 8, p2: 51 },
s11: { cost: 20, p1: 8, p3: 55 },
s12: { cost: 20, p1: 61 }
},
integers: [
's1', 's2', 's3',
's4', 's5', 's6',
's7', 's8', 's9',
's10', 's11', 's12'
]
}
Hi @Ivordir (or others!). I'm new to Linear Solvers, and I need help modeling a simple battery charging scheme. To understand how it works I built a model that doesn't make sense in the real world, but it should help me understand why it doesn't work right now.
So I want to maximize the cost for charging a battery, and am looking for the optimum charge speed and discharge speed
The cost function that needs to be maximized is:
totalCost = 0.5*cs - 0.3*ds
(where cs is charge speed, and ds is discharge speed)
There is a constraint for how full the battery can be loaded:
SoC must stay between 0 and 5
the SoC is calculated as a function from charge speed and discharge speed:
SoC = 2*cs - 1.5*ds
{
direction: 'maximize',
objective: 'totalCost',
constraints: { SoC: { min: 0, max: 5 } },
variables: {
totalCost: { cs: 0.5, ds: -0.3 },
SoC: { cs: 2, ds: -1.5 }
}
}
{ status: 'optimal', result: -0, variables: [] }
So when running the model, I would expect that the maximum cost is where the battery is loaded to its maximum capacity. That would be where ds = 0 and cs = 5 / 2 = 2.5. The totalCost would then be 2.5 * 0.5 = 1.25
But as you can see I get result:-0 and no variables. What is wrong in my model? How do I get the expected result?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.