Comments (4)
Hello,
I think there are some things missing from the code above. For example what is the symbol Mz? Do you mean M? In the expression var w = Array.tabulate(numI)(_0.1) there is an operator missing between the placemarker _ and 0.1. There are other similar cases. Please check the code again and send me a revised version.
Thank you
from optimus.
Oh I'm sorry it got lost in Markdown styling.
Here is the correct version:
implicit val problem = LQProblem(SolverLib.ojalgo)
// Data (filled randomly)
val numI = 5
val I = 0 until numI
val numJ = 5
val J = 0 until numJ
var q = Array.tabulate(numI)(x=>(x+1) * 0.2)
var w = Array.tabulate(numI)(x=>(x+1) * 0.1)
var to = Array.tabulate(numI,numJ)((x,y)=>x+y)
var r = Array.tabulate(numI,numJ)((x,y)=>0.1 * x+0.2 * y )
var c = Array.tabulate(numI,numJ)((x,y)=>x+1+2*y)
var B = 50
var T = Array.tabulate(numJ)(x => (x+2)*3)
var M = 1000
//Variables
val x = Array.tabulate(numI,numJ)((i,j) => MPIntVar( 0 to 1))
val y = Array.tabulate(numI)(i=>MPFloatVar(s"y$i"))
val z = Array.tabulate(numI)(i=>MPIntVar(s"z$i", 0 to 1))
// Optimal Function
maximize(sum(I,J){ (i,j) => w(i)*y(i) })
// Constraints
for ( j <- J ) {
add(sum(I)(i => to(i)(j)*x(i)(j))<:=T(j))
}
for ( i <- I ) {
add(y(i) <:= q(i) + M * z(i))
add(y(i) <:= sum(J)(j => c(i)(j)*x(i)(j)) + M * (1-z(i)))
add(sum(J)(j => x(i)(j)) <:= z(i))
}
add(sum(I,J){(i,j) => c(i)(j)*x(i)(j)} <:= B)
from optimus.
Hello,
The problem is that you define an LQProblem instead of an MIProblem. LQProblem objects are intended for linear programming and use continuous variables, while MIProblem objects represent mixed-integer programming problems and can handle both continuous and integer variables. Nevertheless, maybe these two objects should be merged in order to make the API simpler, or some warning should notify the user for defining float variables in an LQProblem enviroment. I will try to fix this, but for now please just change the first line of your code into:
implicit val problem = MIProblem(SolverLib.ojalgo)
this should work. :)
from optimus.
Thanks a lot. :)
from optimus.
Related Issues (20)
- Constant constraints in gurobi solver. HOT 3
- java.lang.RuntimeException: OJalgo dependency is missing [CBT build] HOT 5
- Constant in cost function HOT 2
- Quadratic objective function + integer variable constraints? HOT 9
- Change in implicit behavior in 3.0.0 ? HOT 5
- OJSolver Outputs Incorrect Solution For Minimization Problem HOT 4
- Comparison of constraints and expressions is broken HOT 2
- Trigger log output HOT 3
- Problem solving models sequentially (Gurobi bronze license) HOT 3
- Warm start HOT 4
- No such method error while instantiating model HOT 3
- java.lang.IllegalStateException when using ojSolver HOT 1
- ojSolver: Time abort not working in case of feasible state HOT 4
- Incorrect quadratic expression? HOT 3
- Value positive is not a member of object optimus.optimization.model.MPFloatVar HOT 4
- Using division in Expressions HOT 1
- Published version 3.4.0 does not work HOT 7
- Returning 0.999999 instead of 1 with binary variables HOT 4
- installation instructions: `sbt dist` not a valid command HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optimus.