Re: [ojAlgo-user] IntegerSolver issue
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Simon G. <si...@ya...> - 2012-07-27 13:56:58
|
Hi, the links you sent me were very helpful, thank you. I've figured out almost everything I need. But I don't know how to add a constant element to the objective function. Using TestOjAlgo.java as a guideline. I'm trying to do this as an example: MIN [6 -5 4][X] - const ST Xi >= 0 i=1,...,3 This is how I'm writing it: final Variable[] objective = new Variable[] { new Variable("X").weight(BigDecimal.valueOf(6)), new Variable("Y").weight(BigDecimal.valueOf(5)), new Variable("Z").weight(BigDecimal.valueOf(4)) }; objective[0].setInteger(true); objective[1].setInteger(true); objective[2].setInteger(true); final ExpressionsBasedModel model = new ExpressionsBasedModel(objective); Any help with the -const part? SG ________________________________ From: Anders Peterson <an...@op...> To: ojAlgo ojAlgo <oja...@li...> Sent: Monday, July 23, 2012 2:02 PM Subject: Re: [ojAlgo-user] IntegerSolver issue Then you've got an old version of ojAlgo. Since v32 ExpessionsBasedModel is no longer abstract (and its previously exiting subclasses have been removed). Get the latest version (I recommend getting the latest snapshot) and have a look at the change log for v32 and the upcoming v33. http://ojalgo.org/change_log.html /Anders On 23 jul 2012, at 20:03, Simon Greaves wrote: > I have read de javadoc for ExpressionsBasedModel, my problem is when I try to build the ExpressionsBasedModel in the same way as in the example in > http://ojalgo.cvs.sourceforge.net/viewvc/ojalgo/TestProj/src/org/ojalgo/optimisation/integer/ > using: > ExpressionsBasedModel ebm=new ExpressionsBasedModel(tmpVariables); (tmpVariables is of the type Variable[]) > > I get an error saying ExpressionsBasedModel is abstract and cannot be instantiated... > > SG > > > > > > From: Anders Peterson <an...@op...> > To: ojAlgo ojAlgo <oja...@li...> > Sent: Friday, July 20, 2012 7:03 AM > Subject: Re: [ojAlgo-user] IntegerSolver issue > > You're not the first to ask about ExpressionsBasedModel. That means you should be able to find something useful in the list archives. > > http://sourceforge.net/mailarchive/forum.php?forum_name=ojalgo-user > http://sourceforge.net/search/?group_id=79000&type_of_search=mlists > > ...and/or you can look at the junit tests for the integer solver: > > http://ojalgo.cvs.sourceforge.net/viewvc/ojalgo/TestProj/src/org/ojalgo/optimisation/integer/ > > Did you read the javadoc for ExpressionsBasedModel and Expression? > > http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html > http://ojalgo.org/generated/org/ojalgo/optimisation/Expression.html > > /Anders > > > On 19 jul 2012, at 23:19, Simon Greaves wrote: > > > Hi, my name is Simon > > I'm trying to use the integer solver in OjAlgo, but I don't understand how to use it. The builder seems to require an ExpressionsBasedModel, which in itself requires a Variable vector. Can you help me out with this? Or point me to an example or documentation regarding this? > > > > I'm solving > > > > min -[X]T[P] / [C]T[X] > > and [C]T[X] <= maxCost > > > > Where [X] is an integer vector > > [P] is a vector of real values > > [C] is a vector of real values > > maxCost is a real value > > > > That is, I want X to maximize [X]T[P] and minimize [C]T[X] while remaining under maxCost > > > > > > > > > > > > > > I've used the Quadratic solver before, this is how I used it: > > > > final QuadraticSolver.Builder tmpBuilder = new QuadraticSolver.Builder(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI); > > final QuadraticSolver tmpSolver = tmpBuilder.build(); > > final OptimisationSolver.Result tmpResult = tmpSolver.solve(); > > final BasicMatrix tmpSolution = tmpResult.getSolution(); > > > > Where I built the MatrixStore objects using: > > final MatrixStore<Double> tmpQ = PrimitiveDenseStore.FACTORY.copy(Q); > > for example... > > > > > > Thanks a lot for any help! > > > > S > > ------------------------------------------------------------------------------ > > Live Security Virtual Conference > > Exclusive live event will cover all the ways today's security and > > threat landscape has changed and how IT managers can respond. Discussions > > will include endpoint security, mobile security and the latest in malware > > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > > ojAlgo-user mailing list > > ojA...@li... > > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |