Comments (7)
Hello @mhucka, you can use decode(value)
and encode(value)
to decode Binary representation [True, False, ....] to Integer; both are included in the class Type
of platypus
This is a small example:
first_variable = algorithm.result[0].variables[0]
problem.types[0].decode(first_variable)
If your integer type is: Integer(-1,1), it will be encoded to 2 bits [X,Y], for instance -1, will be encoded : [False, False] , 0 [False True], 1 [True, False]. This is the explanation.
from platypus.
structureoptimiser.types[0].decode(first_variable)
doesn't work because structureoptimizer
is the class itself and not an instance of the class.
Try algorithm.problem.types[0].decode(first_variable)
.
from platypus.
Thanks, that helped! I got it to work now.
Is this approach (using decode
) the way it must be done? IMHO it would be more convenient and easier to use if the objects in the result
field had Python __repr__
or __str__
functions that did the right thing for printing Integer
values. Perhaps this is something the developers could investigate for a future release?
from platypus.
I agree with mhucka. Also because it is not consistent with the representation that we are given when addressing Continuous problems.
from platypus.
(all thing is in jupyter)
Thank you for suggestion but when I have used
first_variable = algorithm.result[0].variables[0]
Problem.types[0].decode(first_variable)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-145-282c3f73daa6> in <module>
1 first_variable = algorithm.result[0].variables[0]
----> 2 Problem.types[0].decode(first_variable)
AttributeError: type object 'Problem' has no attribute 'types'
And I think it is because of using :
class structureoptimiser(Problem):
def __init__(self):
super(structureoptimiser, self).__init__(…...
Then I have changed it to :
first_variable = algorithm.result[0].variables[0]
structureoptimiser.types[0].decode(first_variable)
but I have gotten:
----------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-138-4dc9e9933591> in <module>
1 first_variable = algorithm.result[0].variables[0]
----> 2 structureoptimiser.types[0].decode(first_variable)
AttributeError: type object 'structureoptimiser' has no attribute 'types'
note :
structureoptimiser.__mro__
(__main__.structureoptimiser, platypus.core.Problem, object)
from platypus.
structureoptimiser.types[0].decode(first_variable) doesn't work because structureoptimizer is the class itself and not an instance of the class.
Try algorithm.problem.types[0].decode(first_variable).
Thank you very much, you are right. it's worked.(Really thank you for time you spent and time you saved for me)
from platypus.
This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.
from platypus.
Related Issues (20)
- Huge amount of identical solutions in Pareto Set when implemented NSGA-II HOT 4
- Is there ask-and-tell interface? HOT 1
- How to include python libraries into an app? HOT 1
- Tests fail on Python 3.11: `inspect.getargspec()` is removed in Python 3.11
- Enable Read the Docs generation on Pull Requests HOT 2
- My inputs and outputs are not lining up when using Integer decision variables HOT 1
- Make it clear that `platypus.Integer` uses gray code HOT 2
- Error in `Missing required option: '--preset <name>'` HOT 1
- Question HOT 6
- Not being able to store Non-Optimized Results HOT 1
- GEX_phenotype function does nothing HOT 1
- Mascot? HOT 3
- Change Indicator for IBEA
- optimal solutions are violating the constraints..
- Usage of LOGGER HOT 2
- More parallel processes than population size HOT 2
- Open discussions page for questions HOT 2
- EpsilonBoxArchive improvements attribute is not consistant HOT 7
- algorithm.run(100) works, algorithm.run(101) or greater doesn't work HOT 9
- Callback function in experimenter HOT 1
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 platypus.