Giter VIP home page Giter VIP logo

Comments (4)

arcteixeira avatar arcteixeira commented on June 9, 2024 1

You're right, it works fine with a main class. I just assumed that if the val x creation worked ok, there was no reason why val y would fail.

Thanks for such prompt reply.

from optimus.

vagmcs avatar vagmcs commented on June 9, 2024

Hello @arcteixeira,

First, let me point out that this code is not correct since you have missed the multiplication operators in the minimize(-8x - 16y + xx + 4y) statement. You should write minimize(-8*x - 16*y + x*x + 4*y). Apart from that, in my case the program runs just fine.

from optimus.

arcteixeira avatar arcteixeira commented on June 9, 2024

Sorry, I cannot copy it correctly!

image
This is the code that I'm trying to run.

from optimus.

vagmcs avatar vagmcs commented on June 9, 2024

I noticed that your example is written in a .sc file which is an ammonite script. I am not sure if everything run as expected. Can you please create a proper main class in Scala and run the same example?

import optimus.optimization._
import optimus.optimization.enums.SolverLib
import optimus.optimization.model.MPFloatVar

object Test extends App {

  implicit val model: MPModel = MPModel(SolverLib.oJSolver)

  // Both variables are positive, that is, bounds are in [0, +inf]
  val x = MPFloatVar.positive("x")
  val y = MPFloatVar.positive("y")

  minimize(-8*x - 16*y + x*x + 4*y)
  subjectTo(
    x + y <:= 5,
    x <:= 3
  )

  start()

  println(s"objective: $objectiveValue")
  println(s"x = ${x.value} y = ${y.value}")

  release()
}

from optimus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.